LogoSearch packages:      

Sourcecode: qt4-x11 version File versions  Download package

QImage QImage::createMaskFromColor ( QRgb  color,
Qt::MaskMode  mode = Qt::MaskInColor 
) const

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.

See also:
createAlphaMask(), createHeuristicMask()

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;
}


Generated by  Doxygen 1.5.1   Back to index