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

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 1867 of file qpixmap.cpp.

References QImage::isNull(), and QPixmap().

Referenced by QMessageBox::aboutQt(), MainWindow::changeIcon(), Q3ImageDrag::decode(), QWindowsVistaStyle::drawControl(), QMotifStyle::drawControl(), QWindowsStyle::drawControl(), QCommonStyle::drawControl(), QPaintEngine::drawImage(), QWindowsStyle::drawPrimitive(), QPicture::exec(), QCommonStyle::generatedIconPixmap(), QStyledItemDelegate::initStyleOption(), load(), loadFromData(), Dialog::loadFromFile(), Dialog::loadFromMemory(), ImageComposer::loadImage(), ImageViewer::open(), QLabel::paintEvent(), QPixmap(), ImageComposer::recalculateResult(), QGLWidget::renderPixmap(), QItemDelegate::selected(), QMotifStyle::standardPixmap(), QCommonStyle::standardPixmap(), MandelbrotWidget::updatePixmap(), and QtFontPropertyManager::valueIcon().

{
    if (image.isNull())
        return QPixmap();

    QPixmapDataFactory *f = QPixmapDataFactory::instance();
    QPixmapData *data = f->create(QPixmapData::PixmapType);
    data->fromImage(image, flags);
    return QPixmap(data);
}


Generated by  Doxygen 1.6.0   Back to index