summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-10-13 15:07:30 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-10-14 11:45:59 (GMT)
commitebe1ff6107cf26ae262961e12ab1eb2917648c1b (patch)
tree123b631cfe70860976ff2491ae266aa035a0c053 /src/gui/image
parentd310f7c710ecb331a9689861f0551eabd38e946e (diff)
downloadQt-ebe1ff6107cf26ae262961e12ab1eb2917648c1b.zip
Qt-ebe1ff6107cf26ae262961e12ab1eb2917648c1b.tar.gz
Qt-ebe1ff6107cf26ae262961e12ab1eb2917648c1b.tar.bz2
Added qt_toRasterPixmap functions.
Similar to the existing qt_toX11Pixmap, this lets us explicitly create pixmaps with the raster pixmap backend. Reviewed-by: Gunnar Sletta
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qpixmap_raster.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp
index 3667e5b..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)
{