mask()

Image / Pixels

Description

Applies a mask to a PImage. The mask image is a grayscale image where white pixels are opaque and black pixels are transparent.

Syntax

img.mask(const PImage& m)

Parameters

NameTypeDescription
mPImagegrayscale image to use as mask

Returns

void

Related

Under the Hood

From Processing.h:

void mask(const PImage& m) { for (int i=0; i<width*height && i<(int)m.pixels.size(); i++) { int a = (m.pixels[i]>>16)&0xFF; pixels[i] = (pixels[i]&0x00FFFFFF)|(a<<24); } dirty = true; } void mask(const PImage* m) { if (m) mask(*m); } void mask(const PImage* m) { if (m) mask(*m);