Creates and returns a mask for this image based on the given color value. If the mode is MaskInColor (the default value), all pixels matching color will be opaque pixels in the mask. If mode is MaskOutColor, all pixels matching the given color will be transparent.
Definition at line 4129 of file qimage.cpp. References height(), invertPixels(), pixel(), setPixel(), size(), and width(). Referenced by QPixmap::createMaskFromColor(). {
QImage maskImage(size(), QImage::Format_MonoLSB);
for (int w = 0; w < width(); w++) {
for (int h = 0; h < height(); h++) {
if ((uint) pixel(w, h) == color)
maskImage.setPixel(w, h, Qt::color1);
else
maskImage.setPixel(w, h, Qt::color0);
}
}
if (mode == Qt::MaskOutColor)
maskImage.invertPixels();
return maskImage;
}
|