summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Bakken <anders.bakken@nokia.com>2010-03-26 18:17:39 (GMT)
committerAnders Bakken <anders.bakken@nokia.com>2010-03-26 18:20:16 (GMT)
commitec401f7a4c682b3ccdbc64edb4aa9881830b45cf (patch)
tree48bdddd9d3611b2b14afd4e90f02bd4661aefa78
parent96d6bff54942be11458801edc5c59e2cf646253c (diff)
downloadQt-ec401f7a4c682b3ccdbc64edb4aa9881830b45cf.zip
Qt-ec401f7a4c682b3ccdbc64edb4aa9881830b45cf.tar.gz
Qt-ec401f7a4c682b3ccdbc64edb4aa9881830b45cf.tar.bz2
Refactor QDirectFBPixmap::fromImage slightly
Clean up the function a little and make sure I don't call QImage::hasAlphaChannel twice for opaque images. Reviewed-by: muthu <qt-info@nokia.com>
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
index f2fd699..80366d1 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
@@ -290,27 +290,22 @@ bool QDirectFBPixmapData::fromDataBufferDescription(const DFBDataBufferDescripti
void QDirectFBPixmapData::fromImage(const QImage &img,
Qt::ImageConversionFlags flags)
{
- if (img.depth() == 1 || img.format() == QImage::Format_RGB32) {
- fromImage(img.convertToFormat(screen->alphaPixmapFormat()), flags);
- return;
- }
-
- if (img.hasAlphaChannel()
+ if (img.depth() == 1) {
+ alpha = true;
#ifndef QT_NO_DIRECTFB_OPAQUE_DETECTION
- && (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img))
-#endif
- ) {
+ } else if (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img)) {
alpha = true;
- imageFormat = screen->alphaPixmapFormat();
- } else {
- alpha = false;
- imageFormat = screen->pixelFormat();
+#else
+ } else if (img.hasAlphaChannel()) {
+ alpha = true;
+#endif
}
+ imageFormat = alpha ? screen->alphaPixmapFormat() : screen->pixelFormat();
QImage image;
if ((flags & ~Qt::NoOpaqueDetection) != Qt::AutoColor) {
image = img.convertToFormat(imageFormat, flags);
flags = Qt::AutoColor;
- } else if (img.format() == QImage::Format_RGB32) {
+ } else if (img.format() == QImage::Format_RGB32 || img.depth() == 1) {
image = img.convertToFormat(imageFormat, flags);
} else {
image = img;