diff options
Diffstat (limited to 'src/gui/image/qpixmap_raster.cpp')
-rw-r--r-- | src/gui/image/qpixmap_raster.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index ad68b07..fc76dc3 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -55,6 +55,29 @@ QT_BEGIN_NAMESPACE const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; +QPixmap qt_toRasterPixmap(const QImage &image) +{ + QPixmapData *data = + new QRasterPixmapData(image.depth() == 1 + ? QPixmapData::BitmapType + : QPixmapData::PixmapType); + + data->fromImage(image, Qt::AutoColor); + + return QPixmap(data); +} + +QPixmap qt_toRasterPixmap(const QPixmap &pixmap) +{ + if (pixmap.isNull()) + return QPixmap(); + + if (QPixmap(pixmap).data_ptr()->classId() == QPixmapData::RasterClass) + return pixmap; + + return qt_toRasterPixmap(pixmap.toImage()); +} + QRasterPixmapData::QRasterPixmapData(PixelType type) : QPixmapData(type, RasterClass) { @@ -64,6 +87,11 @@ QRasterPixmapData::~QRasterPixmapData() { } +QPixmapData *QRasterPixmapData::createCompatiblePixmapData() const +{ + return new QRasterPixmapData(pixelType()); +} + void QRasterPixmapData::resize(int width, int height) { QImage::Format format; |