Changeset View
Changeset View
Standalone View
Standalone View
src/PlatformBackends/X11ImageGrabber.cpp
Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Line(s) | 187 | case 32: | |||
---|---|---|---|---|---|
189 | break; | 189 | break; | ||
190 | default: | 190 | default: | ||
191 | return QPixmap(); // we don't know | 191 | return QPixmap(); // we don't know | ||
192 | } | 192 | } | ||
193 | 193 | | |||
194 | // The RGB32 format requires data format 0xffRRGGBB, ensure that this fourth byte really is 0xff | 194 | // The RGB32 format requires data format 0xffRRGGBB, ensure that this fourth byte really is 0xff | ||
195 | if (format == QImage::Format_RGB32) { | 195 | if (format == QImage::Format_RGB32) { | ||
196 | quint32 *data = reinterpret_cast<quint32 *>(xcbImage->data); | 196 | quint32 *data = reinterpret_cast<quint32 *>(xcbImage->data); | ||
197 | for (int i = 0; i < xcbImage->width * xcbImage->height; i++) { | 197 | | ||
198 | const auto imageSize = xcbImage->width * xcbImage->height; | ||||
199 | | ||||
200 | bool sanitationNeeded = false; | ||||
201 | // Check the first 1000 pixels. If they don't have any bogus alpha values, assume the entire image to be sane. | ||||
202 | for (int i = 0; i < qMin(1000, imageSize); ++i) { | ||||
203 | if (data[i] != (data[i] | 0xff000000)) { | ||||
204 | sanitationNeeded = true; | ||||
205 | break; | ||||
206 | } | ||||
207 | } | ||||
208 | | ||||
209 | if (sanitationNeeded) { | ||||
210 | for (int i = 0; i < imageSize; ++i) { | ||||
198 | data[i] |= 0xff000000; | 211 | data[i] |= 0xff000000; | ||
199 | } | 212 | } | ||
200 | } | 213 | } | ||
214 | } | ||||
201 | 215 | | |||
202 | QImage image(xcbImage->data, xcbImage->width, xcbImage->height, format); | 216 | QImage image(xcbImage->data, xcbImage->width, xcbImage->height, format); | ||
203 | 217 | | |||
204 | if (image.isNull()) { | 218 | if (image.isNull()) { | ||
205 | return QPixmap(); | 219 | return QPixmap(); | ||
206 | } | 220 | } | ||
207 | 221 | | |||
208 | // work around an abort in QImage::color | 222 | // work around an abort in QImage::color | ||
▲ Show 20 Lines • Show All 506 Lines • Show Last 20 Lines |