summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpaintengine_x11.cpp
diff options
context:
space:
mode:
authorTrond Kjernåsen <trond@trolltech.com>2009-06-02 15:55:58 (GMT)
committerTrond Kjernåsen <trond@trolltech.com>2009-06-02 15:58:00 (GMT)
commitb3ebeff77de9f3e53bea08bfd09eac9cb3a32be3 (patch)
tree6d894918b6df435037b531b8341ff06dc87915f1 /src/gui/painting/qpaintengine_x11.cpp
parente8c6c0cf4d341572e4740940590b0301d208d239 (diff)
downloadQt-b3ebeff77de9f3e53bea08bfd09eac9cb3a32be3.zip
Qt-b3ebeff77de9f3e53bea08bfd09eac9cb3a32be3.tar.gz
Qt-b3ebeff77de9f3e53bea08bfd09eac9cb3a32be3.tar.bz2
Fixed a byte ordering issue when using the raster graphicssystem.
The R and B channels were swapped on little endian machines with BGR layout. Task-number: 254934 Reviewed-by: Samuel
Diffstat (limited to 'src/gui/painting/qpaintengine_x11.cpp')
-rw-r--r--src/gui/painting/qpaintengine_x11.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp
index 9cc9683..2e6d593 100644
--- a/src/gui/painting/qpaintengine_x11.cpp
+++ b/src/gui/painting/qpaintengine_x11.cpp
@@ -1826,9 +1826,10 @@ Q_GUI_EXPORT void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const Q
const int h = rect.height();
QImage im;
- if ((QSysInfo::ByteOrder == QSysInfo::BigEndian
- && ((ImageByteOrder(X11->display) == LSBFirst) || bgr_layout))
- || (ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian))
+ int image_byte_order = ImageByteOrder(X11->display);
+ if ((QSysInfo::ByteOrder == QSysInfo::BigEndian && ((image_byte_order == LSBFirst) || bgr_layout))
+ || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)
+ || (image_byte_order == LSBFirst && bgr_layout))
{
im = image.copy(rect);
const int iw = im.bytesPerLine() / 4;
@@ -1836,19 +1837,21 @@ Q_GUI_EXPORT void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const Q
for (int i=0; i < h; i++) {
uint *p = data;
uint *end = p + w;
- if (bgr_layout && ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
+ if (bgr_layout && image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
while (p < end) {
*p = ((*p << 8) & 0xffffff00) | ((*p >> 24) & 0x000000ff);
p++;
}
- } else if ((ImageByteOrder(X11->display) == LSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
- || (ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) {
+ } else if ((image_byte_order == LSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
+ || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) {
while (p < end) {
*p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000)
| ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff);
p++;
}
- } else if (ImageByteOrder(X11->display) == MSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+ } else if ((image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
+ || (image_byte_order == LSBFirst && bgr_layout))
+ {
while (p < end) {
*p = ((*p << 16) & 0x00ff0000) | ((*p >> 16) & 0x000000ff)
| ((*p ) & 0xff00ff00);