Logo Search packages:      
Sourcecode: qt4-x11 version File versions

void QPixmap::fill ( const QColor fillColor = Qt::white  ) 

Fills the pixmap with the given fillColor.

See also:
{QPixmap::Pixmap Transformations}{Pixmap Transformations}

Definition at line 189 of file qpixmap_raster.cpp.

References QColor::alpha, QColor::blue, detach(), QColor::green, QColor::red, and QColor::rgba().

Referenced by QItemDelegate::decoration(), QCleanlooksStyle::drawComplexControl(), QPlastiqueStyle::drawComplexControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QPlastiqueStyle::drawPrimitive(), QGraphicsSvgItem::paint(), QCursor::QCursor(), and Q3ComboBox::updateMask().

{
    uint pixel;
    detach();
    if (data->image.depth() == 1) {
        int gray = qGray(fillColor.rgba());
        // Pick the best approximate color in the image's colortable.
        if (qAbs(qGray(data->image.color(0)) - gray) < qAbs(qGray(data->image.color(1)) - gray)) {
            pixel = 0;
        } else {
            pixel = 1;
        }
    } else if (data->image.depth() == 32
#ifdef Q_WS_QWS
               || data->image.depth() == 16
#endif
        ) {
        int alpha = fillColor.alpha();
        if (alpha != 255) {
            if (data->image.format() == QImage::Format_RGB32
#ifdef Q_WS_QWS
                || data->image.format() == QImage::Format_RGB16
#endif
                )
                data->image = data->image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
            // Premultiply pixel value.
            pixel = qRgba(fillColor.red() * alpha / 255,
                          fillColor.green() * alpha / 255,
                          fillColor.blue() * alpha / 255,
                          alpha);
#ifdef Q_WS_QWS
        } else if (data->image.depth() == 16) {
            pixel = qt_convRgbTo16(fillColor.rgba());
#endif
        } else {
            pixel = fillColor.rgba();
        }

    } else {
        pixel = 0;
        // ### what about 8 bits
    }

    data->image.fill(pixel);
}


Generated by  Doxygen 1.6.0   Back to index