The source and destination nativeRaster images must have the same dimensions.

nr_copy_into(dst, src, mask = NULL, color = "black", invert = FALSE)

Arguments

src, dst

Source and destination nativeRaster images

mask

Optional nativeRaster image to use as a mask. Default: NULL (no mask)

color

Copy the source pixels into the destination where the mask matches this color. See also the invert argument.

invert

Invert masking so that pixels are copied where the mask does not match the specified color. Default: FALSE

Value

The 'dst' nativeRaster

Details

If the nativeRaster images are of different sizes or alpha blending is required, use the nr_blit() function.

Examples

nr1 <- nr_new(200, 100, 'hotpink')
nr2 <- nr_new(200, 100, 'green')
nr_copy_into(nr1, nr2)
plot(nr1)


# Copy with mask
logo <- png::readPNG(system.file("img", "Rlogo.png", package="png"), native = TRUE)
src <- nr_duplicate(logo)
dst <- nr_duplicate(logo)
nr_fill(src, 'hotpink')

nr_copy_into(dst, src, mask = logo, col = 0L, invert = TRUE)
plot(dst, T)