src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 33 3e2da88830cd
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp	Fri Apr 16 15:50:13 2010 +0300
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp	Mon May 03 13:17:34 2010 +0300
@@ -174,6 +174,8 @@
 bool QDirectFBPixmapData::fromFile(const QString &filename, const char *format,
                                    Qt::ImageConversionFlags flags)
 {
+    if (!QFile::exists(filename))
+        return false;
     if (flags == Qt::AutoColor) {
         if (filename.startsWith(QLatin1Char(':'))) { // resource
             QFile file(filename);
@@ -288,27 +290,22 @@
 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))
+    } else if (flags & Qt::NoOpaqueDetection || QDirectFBPixmapData::hasAlphaChannel(img)) {
+        alpha = true;
+#else
+    } else if (img.hasAlphaChannel()) {
+        alpha = true;
 #endif
-        ) {
-        alpha = true;
-        imageFormat = screen->alphaPixmapFormat();
-    } else {
-        alpha = false;
-        imageFormat = screen->pixelFormat();
     }
+    imageFormat = alpha ? screen->alphaPixmapFormat() : screen->pixelFormat();
     QImage image;
-    if (flags != Qt::AutoColor) {
+    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;
@@ -425,7 +422,7 @@
 
     Q_ASSERT(dfbSurface);
 
-    alpha = (color.alpha() < 255);
+    alpha |= (color.alpha() < 255);
 
     if (alpha && isOpaqueFormat(imageFormat)) {
         QSize size;