Newer
Older
invertedlogic / LGN-IP3870 / qtpyui / patches / smooth.diff
--- qtopia-phone-4.3.0/qtopiacore/qt/src/gui/image/qpixmap_raster.cpp.orig	2007-10-29 15:14:20.000000000 +0800
+++ qtopia-phone-4.3.0/qtopiacore/qt/src/gui/image/qpixmap_raster.cpp	2009-01-01 22:39:34.000000000 +0800
@@ -454,6 +454,40 @@
     return data->image;
 }
 
+#include <private/qdrawhelper_p.h>
+
+static QImage convert32to32through16dither(const QImage &src)
+{
+    QImage dst;
+    if ( src.format() != QImage::Format_ARGB32 ) 
+        return dst;
+    int w = src.width();
+    int h = src.height();
+    dst = QImage(w, h, QImage::Format_ARGB32);
+
+    uchar *dstBits = dst.bits();
+    const uchar *srcBits = src.bits();
+    
+    for (int y = 0; y < h; y++) {
+        uint *s = (uint*)srcBits;
+        uint *b = (uint*)dstBits;
+        uint *end = b + w;
+        int x = 0;
+        while (b < end) {
+            uint d = qt_bayer_matrix[y & 15][x & 15] << 11;
+            *b++ = ( *s & 0xff000000 ) |
+                   ( ((( 7967 * ((*s & 0xFF0000)>>13) + d) >>  0) & 0x00F80000) ) |
+		   ( (((16192 * ((*s & 0x00FF00)>> 5) + d) >>  9) & 0x0000FC00) ) |
+                   ( (((63736 * ((*s & 0x0000FF)>> 0) + d) >> 16) & 0x000000F8) );
+            s++;
+            x++;
+        }
+        srcBits += src.bytesPerLine();
+        dstBits += dst.bytesPerLine();
+    }
+    return dst;
+}
+
 QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags )
 {
     Q_UNUSED(flags);
@@ -468,6 +502,10 @@
         break;
     case QImage::Format_RGB32:
     case QImage::Format_ARGB32_Premultiplied:
+    	if ( qt_screen->depth() == 16 ) {
+	    pixmap.data->image = convert32to32through16dither(image.convertToFormat(QImage::Format_ARGB32));
+            break;
+	}
     case QImage::Format_RGB16:
         pixmap.data->image = image;
         break;