diff options
author | Morten Engvoldsen <morten.engvoldsen@nokia.com> | 2010-10-06 11:12:30 (GMT) |
---|---|---|
committer | Morten Engvoldsen <morten.engvoldsen@nokia.com> | 2010-10-06 11:12:30 (GMT) |
commit | eaef6f8b4a7ad637a59b4fe2ec623d26a7cae96f (patch) | |
tree | 4868b097a6e1d5814ae557c464f70c879ffd8e9d /src/gui/image/qjpeghandler.cpp | |
parent | fe0319a84082cb97a2007ca82af153a785a0938e (diff) | |
parent | 24c89f6d1c090ab670d4f883d06cd0413c2ecc65 (diff) | |
download | Qt-eaef6f8b4a7ad637a59b4fe2ec623d26a7cae96f.zip Qt-eaef6f8b4a7ad637a59b4fe2ec623d26a7cae96f.tar.gz Qt-eaef6f8b4a7ad637a59b4fe2ec623d26a7cae96f.tar.bz2 |
Merge branch '4.7' of git@scm.dev.nokia.troll.no:qt/qt-doc-team into 4.7
Diffstat (limited to 'src/gui/image/qjpeghandler.cpp')
-rw-r--r-- | src/gui/image/qjpeghandler.cpp | 32 |
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; } |