# HG changeset patch # User Teemu Piippo # Date 1487885819 -7200 # Node ID 3defab8cfd93f888842ef4bd6be6e8d6e58bb05d # Parent 430ffa371d2ab50e19627a0555294a162dc62c15 Changed QByteArray to QVector to avoid that ugly reinterpret_cast. diff -r 430ffa371d2a -r 3defab8cfd93 src/glrenderer.cpp --- a/src/glrenderer.cpp Thu Feb 23 23:29:16 2017 +0200 +++ b/src/glrenderer.cpp Thu Feb 23 23:36:59 2017 +0200 @@ -813,12 +813,12 @@ // Read the current render to a buffer of pixels. We use RGBA format even though the image should be fully opaque at all times. // This is because apparently GL_RGBA/GL_UNSIGNED_BYTE is the only setting pair that is guaranteed to actually work! // ref: https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glReadPixels.xml - QByteArray pixelData; + QVector pixelData; pixelData.resize(4 * width() * height()); glReadPixels(0, 0, width(), height(), GL_RGBA, GL_UNSIGNED_BYTE, pixelData.data()); // Prepare the image and return it. It appears that GL and Qt formats have red and blue swapped and the Y axis flipped. - QImage image {reinterpret_cast(pixelData.constData()), width(), height(), QImage::Format_ARGB32}; + QImage image {pixelData.constData(), width(), height(), QImage::Format_ARGB32}; return image.rgbSwapped().mirrored(); }