Changeset View
Changeset View
Standalone View
Standalone View
effects/screenshot/screenshot.cpp
Show First 20 Lines • Show All 652 Lines • ▼ Show 20 Line(s) | |||||
653 | 653 | | |||
654 | void ScreenShotEffect::convertFromGLImage(QImage &img, int w, int h) | 654 | void ScreenShotEffect::convertFromGLImage(QImage &img, int w, int h) | ||
655 | { | 655 | { | ||
656 | // from QtOpenGL/qgl.cpp | 656 | // from QtOpenGL/qgl.cpp | ||
657 | // Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 657 | // Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | ||
658 | // see https://github.com/qt/qtbase/blob/dev/src/opengl/qgl.cpp | 658 | // see https://github.com/qt/qtbase/blob/dev/src/opengl/qgl.cpp | ||
659 | if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { | 659 | if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { | ||
660 | // OpenGL gives RGBA; Qt wants ARGB | 660 | // OpenGL gives RGBA; Qt wants ARGB | ||
661 | uint *p = (uint*)img.bits(); | 661 | uint *p = reinterpret_cast<uint*>(img.bits()); | ||
zzag: Do compilers bark about using c-style casts? | |||||
The warning is: apol: The warning is:
`kwin/effects/screenshot/screenshot.cpp:671:23: warning: cast from 'uchar *'… | |||||
zzag: Coding style nitpick: add whitespace before `*`. | |||||
662 | uint *end = p + w * h; | 662 | uint *end = p + w * h; | ||
663 | while (p < end) { | 663 | while (p < end) { | ||
664 | uint a = *p << 24; | 664 | uint a = *p << 24; | ||
665 | *p = (*p >> 8) | a; | 665 | *p = (*p >> 8) | a; | ||
666 | p++; | 666 | p++; | ||
667 | } | 667 | } | ||
668 | } else { | 668 | } else { | ||
669 | // OpenGL gives ABGR (i.e. RGBA backwards); Qt wants ARGB | 669 | // OpenGL gives ABGR (i.e. RGBA backwards); Qt wants ARGB | ||
670 | for (int y = 0; y < h; y++) { | 670 | for (int y = 0; y < h; y++) { | ||
671 | uint *q = (uint*)img.scanLine(y); | 671 | uint *q = (uint*) (img.scanLine(y)); | ||
zzag: Looks like you forgot to add reinterpret_cast. | |||||
672 | for (int x = 0; x < w; ++x) { | 672 | for (int x = 0; x < w; ++x) { | ||
673 | const uint pixel = *q; | 673 | const uint pixel = *q; | ||
674 | *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | 674 | *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | ||
675 | | (pixel & 0xff00ff00); | 675 | | (pixel & 0xff00ff00); | ||
676 | 676 | | |||
677 | q++; | 677 | q++; | ||
678 | } | 678 | } | ||
679 | } | 679 | } | ||
Show All 33 Lines |
Do compilers bark about using c-style casts?