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

QImage QImage::convertToFormat ( Format  format,
Qt::ImageConversionFlags  flags = Qt::AutoColor 
) const

Returns a copy of the image in the given format.

The specified image conversion flags control how the image data is handled during the conversion process.

See also:
{QImage::Image Format}{Image Format}

Definition at line 2935 of file qimage.cpp.

References convertToFormat(), d, dotsPerMeterX(), dotsPerMeterY(), QImage(), setDotsPerMeterX(), and setDotsPerMeterY().

Referenced by convertToFormat(), QGLWidget::convertToGLFormat(), createAlphaMask(), createHeuristicMask(), QPaintEngine::drawImage(), QPixmap::fromImage(), QBitmap::fromImage(), QCommonStyle::generatedIconPixmap(), QCursor::QCursor(), QItemDelegate::selected(), setAlphaChannel(), QPixmap::setMask(), and QCommonStyle::standardPixmap().

{
    if (!d || d->format == format)
        return *this;

    const Image_Converter *converterPtr = &converter_map[d->format][format];
    Image_Converter converter = *converterPtr;
    if (converter) {
        QImage image(d->width, d->height, format);
        image.setDotsPerMeterY(dotsPerMeterY());
        image.setDotsPerMeterX(dotsPerMeterX());

#if !defined(QT_NO_IMAGE_TEXT)
        image.d->text = d->text;
        image.d->text_lang = d->text_lang;
#endif // !QT_NO_IMAGE_TEXT

        converter(image.d, d, flags);
        return image;
    }

#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
    if (format == Format_RGB16) {
        QImage tmp;
        if (d->format == Format_RGB32 || d->format == Format_ARGB32)
            tmp = *this;
        else
            tmp = convertToFormat(Format_RGB32, flags);
        QImage image(d->width, d->height, format);
        image.setDotsPerMeterY(dotsPerMeterY());
        image.setDotsPerMeterX(dotsPerMeterX());

#if !defined(QT_NO_IMAGE_TEXT)
        image.d->text = d->text;
        image.d->text_lang = d->text_lang;
#endif // !QT_NO_IMAGE_TEXT

        convert_32_to_16(image.d, tmp.d, flags);
        return image;
    } else if (d->format == Format_RGB16) {
        int targetDepth = depthForFormat(format);
        QImage image(d->width, d->height, targetDepth == 32 ? format : Format_RGB32);
        image.setDotsPerMeterY(dotsPerMeterY());
        image.setDotsPerMeterX(dotsPerMeterX());

#if !defined(QT_NO_IMAGE_TEXT)
        image.d->text = d->text;
        image.d->text_lang = d->text_lang;
#endif // !QT_NO_IMAGE_TEXT

        convert_16_to_32(image.d, d, flags);
        if (targetDepth == 32)
            return image;
        else
            return image.convertToFormat(format);
    }
#endif

    return QImage();
}


Generated by  Doxygen 1.6.0   Back to index