Qt 4.8
Functions
qwaylandreadbackeglcontext.cpp File Reference
#include "qwaylandreadbackeglcontext.h"
#include "../../../eglconvenience/qeglconvenience.h"
#include <QtOpenGL/QGLContext>
#include <QtOpenGL/private/qglextensions_p.h>
#include "qwaylandshmsurface.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 53 of file qwaylandreadbackeglcontext.cpp.

Referenced by QWaylandReadbackEglContext::swapBuffers().

54 {
55  const int width = img.width();
56  const int height = img.height();
57 
58  if (pixel_type == GL_UNSIGNED_INT_8_8_8_8_REV
59  || (pixel_type == GL_UNSIGNED_BYTE && QSysInfo::ByteOrder == QSysInfo::LittleEndian))
60  {
61  for (int i = 0; i < height; ++i) {
62  uint *p = (uint *) img.scanLine(i);
63  for (int x = 0; x < width; ++x)
64  p[x] = ((p[x] << 16) & 0xff0000) | ((p[x] >> 16) & 0xff) | (p[x] & 0xff00ff00);
65  }
66  } else {
67  for (int i = 0; i < height; ++i) {
68  uint *p = (uint *) img.scanLine(i);
69  for (int x = 0; x < width; ++x)
70  p[x] = (p[x] << 8) | ((p[x] >> 24) & 0xff);
71  }
72  }
73 }
#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