LogoSearch packages:      

Sourcecode: qt4-x11 version File versions  Download package

void QImage::invertPixels ( InvertMode  mode = InvertRgb  ) 

Inverts all pixel values in the image.

The given invert mode only have a meaning when the image's depth is 32. The default mode is InvertRgb, which leaves the alpha channel unchanged. If the mode is InvertRgba, the alpha bits are also inverted.

Inverting an 8-bit image means to replace all pixels using color index i with a pixel using color index 255 minus i. The same is the case for a 1-bit image. Note that the color table is not changed.

See also:
{QImage::Image Transformations}{Image Transformations}

Definition at line 1886 of file qimage.cpp.

References depth(), and detach().

Referenced by createMaskFromColor(), BasicToolsPlugin::filterImage(), and QBitmap::fromImage().

{
    if (!d)
        return;

    detach();
    if (depth() != 32) {
        // number of used bytes pr line
        int bpl = (d->width * d->depth + 7) / 8;
        int pad = d->bytes_per_line - bpl;
        uchar *sl = d->data;
        for (int y=0; y<d->height; ++y) {
            for (int x=0; x<bpl; ++x)
                *sl++ ^= 0xff;
            sl += pad;
        }
    } else {
        quint32 *p = (quint32*)d->data;
        quint32 *end = (quint32*)(d->data + d->nbytes);
        uint xorbits = (mode == InvertRgba) ? 0xffffffff : 0x00ffffff;
        while (p < end)
            *p++ ^= xorbits;
    }
}


Generated by  Doxygen 1.5.1   Back to index