branches/KDE/4.3/kdelibs/khtml/imload

View: New views
1 Messages — Rating Filter:   Alert me  

branches/KDE/4.3/kdelibs/khtml/imload

by Bugzilla from maksim@kde.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

SVN commit 1042272 by orlovich:

Fix unaligned accesses (since they crash on many archs).

BUG: 210574


 M  +15 -7     image.cpp  


--- branches/KDE/4.3/kdelibs/khtml/imload/image.cpp #1042271:1042272
@@ -33,6 +33,7 @@
 #include <QtGui/QPainter>
 #include <limits.h>
 #include <kdebug.h>
+#include <config.h> //For endian
 
 namespace khtmlImLoad {
 
@@ -321,17 +322,24 @@
         //Premultiply. Note that this is assuming that any combination
         //Will not actually look at the pixel.
         QRgb* dst = reinterpret_cast<QRgb*>(plane->image.scanLine(loaderScanline));
-        QRgb* src = reinterpret_cast<QRgb*>(data);
+        uchar* src = data;
         int planeImageWidth = plane->image.width();
         for (int x = 0; x < planeImageWidth; ++x)
         {
-            QRgb col = src[x];
-            unsigned a = qAlpha(col);
-            unsigned r = qRed(col);
-            unsigned g = qGreen(col);
-            unsigned b = qBlue(col);
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN || defined(__BIG_ENDIAN__)
+            unsigned a = src[0];
+            unsigned r = src[1];
+            unsigned g = src[2];
+            unsigned b = src[3];
+#else
+            unsigned a = src[3];
+            unsigned r = src[2];
+            unsigned g = src[1];
+            unsigned b = src[0];
+#endif
             dst[x]  = qRgba(premulComponent(r, a), premulComponent(g, a),
-                            premulComponent(b, a), a);
+                              premulComponent(b, a), a);
+            src += 4;
         }
     }
 
_______________________________________________
Khtml-cvs mailing list
Khtml-cvs@...
https://mail.kde.org/mailman/listinfo/khtml-cvs