Qt 4.8
Functions
qwaylandreadbackglxcontext.cpp File Reference
#include "qwaylandreadbackglxcontext.h"
#include "qwaylandshmsurface.h"
#include "qwaylandreadbackglxwindow.h"
#include <QtCore/QDebug>

Go to the source code of this file.

Functions

static void qgl_byteSwapImage (QImage &img, GLenum pixel_type)
 

Function Documentation

◆ qgl_byteSwapImage()

static void qgl_byteSwapImage ( QImage img,
GLenum  pixel_type 
)
inlinestatic

Definition at line 49 of file qwaylandreadbackglxcontext.cpp.

Referenced by QWaylandReadbackGlxContext::swapBuffers().

50 {
51  const int width = img.width();
52  const int height = img.height();
53 
54  if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV
55  || (pixel_type == GL_UNSIGNED_BYTE && QSysInfo::ByteOrder == QSysInfo::LittleEndian))
56  {
57  for (int i = 0; i < height; ++i) {
58  uint *p = (uint *) img.scanLine(i);
59  for (int x = 0; x < width; ++x)
60  p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00);
61  }
62  } else {
63  for (int i = 0; i < height; ++i) {
64  uint *p = (uint *) img.scanLine(i);
65  for (int x = 0; x < width; ++x)
66  p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff);
67  }
68  }
69 }
#define GL_UNSIGNED_INT_8_8_8_8_REV
unsigned int uint
Definition: qglobal.h:996
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
#define GL_UNSIGNED_BYTE
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition: qimage.cpp:1886