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

QPixmap QPixmap::fromImage ( const QImage image,
Qt::ImageConversionFlags  flags = Qt::AutoColor 
) [static]

Converts the given image to a pixmap using the specified flags to control the conversion. The flags argument is a bitwise-OR of the {Qt::ImageConversionFlags}. Passing 0 for flags sets all the default options.

In case of monochrome and 8-bit images, the image is first converted to a 32-bit pixmap and then filled with the colors in the color table. If this is too expensive an operation, you can use QBitmap::fromImage() instead.

See also:
toImage(), {QPixmap::Pixmap Conversion}{Pixmap Conversion}

Reimplemented in QBitmap.

Definition at line 479 of file qpixmap_raster.cpp.

References QImage::convertToFormat(), data, QImage::format(), and QImage::hasAlphaChannel().

Referenced by QMessageBox::aboutQt(), alphaChannel(), copy(), Q3ImageDrag::decode(), QWindowsVistaStyle::drawControl(), QMotifStyle::drawControl(), QWindowsStyle::drawControl(), QCommonStyle::drawControl(), QPaintEngine::drawImage(), QWindowsStyle::drawPrimitive(), QPicture::exec(), QBitmap::fromImage(), QCommonStyle::generatedIconPixmap(), load(), loadFromData(), QLabel::paintEvent(), QPixmap(), QGLWidget::renderPixmap(), QItemDelegate::selected(), QMotifStyle::standardPixmap(), QCommonStyle::standardPixmap(), and transformed().

{
    Q_UNUSED(flags);
    QPixmap pixmap;

    switch (image.format()) {
    case QImage::Format_Mono:
    case QImage::Format_MonoLSB:
        pixmap.data->image = image.hasAlphaChannel()
                             ? image.convertToFormat(QImage::Format_ARGB32_Premultiplied)
                             : image.convertToFormat(QImage::Format_RGB32);
        break;
    case QImage::Format_RGB32:
    case QImage::Format_ARGB32_Premultiplied:
    case QImage::Format_RGB16:
        pixmap.data->image = image;
        break;
    default:
        pixmap.data->image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
        break;
    }
    return pixmap;
}


Generated by  Doxygen 1.6.0   Back to index