summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraavit <qt-info@nokia.com>2010-09-24 14:49:19 (GMT)
committeraavit <qt-info@nokia.com>2010-09-24 15:31:23 (GMT)
commitd5e6aa0a70004338a644387ba3d682a73fa169a9 (patch)
treece2b7324bb3e39e3d47e9a4528aa6b82fa8bfaba
parent8b594b7f9373b82938aebbc056b18657034abce2 (diff)
downloadQt-d5e6aa0a70004338a644387ba3d682a73fa169a9.zip
Qt-d5e6aa0a70004338a644387ba3d682a73fa169a9.tar.gz
Qt-d5e6aa0a70004338a644387ba3d682a73fa169a9.tar.bz2
Optimization of pixel conversion when storing jpeg
Reviewed-by: Kim
-rw-r--r--src/gui/image/qjpeghandler.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp
index b9eda05..d47cc82 100644
--- a/src/gui/image/qjpeghandler.cpp
+++ b/src/gui/image/qjpeghandler.cpp
@@ -648,22 +648,28 @@ static bool write_jpeg_image(const QImage &image, QIODevice *device, int sourceQ
break;
case QImage::Format_RGB32:
case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied: {
- const QRgb* rgb = (const QRgb*)image.constScanLine(cinfo.next_scanline);
- for (int i=0; i<w; i++) {
- *row++ = qRed(*rgb);
- *row++ = qGreen(*rgb);
- *row++ = qBlue(*rgb);
- ++rgb;
+ case QImage::Format_ARGB32_Premultiplied:
+ {
+ const QRgb* rgb = (const QRgb*)image.constScanLine(cinfo.next_scanline);
+ for (int i=0; i<w; i++) {
+ *row++ = qRed(*rgb);
+ *row++ = qGreen(*rgb);
+ *row++ = qBlue(*rgb);
+ ++rgb;
+ }
}
break;
- }
default:
- for (int i=0; i<w; i++) {
- QRgb pix = image.pixel(i, cinfo.next_scanline);
- *row++ = qRed(pix);
- *row++ = qGreen(pix);
- *row++ = qBlue(pix);
+ {
+ // (Testing shows that this way is actually faster than converting to RGB888 + memcpy)
+ QImage rowImg = image.copy(0, cinfo.next_scanline, w, 1).convertToFormat(QImage::Format_RGB32);
+ const QRgb* rgb = (const QRgb*)rowImg.constScanLine(0);
+ for (int i=0; i<w; i++) {
+ *row++ = qRed(*rgb);
+ *row++ = qGreen(*rgb);
+ *row++ = qBlue(*rgb);
+ ++rgb;
+ }
}
break;
}