summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qjpeghandler.cpp
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-09-22 02:31:46 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-09-22 02:31:46 (GMT)
commit80c2e1211065f606c6f39e708a74afad1c624663 (patch)
tree48f9a9ae5e308c9c4c0d43a39d78ace5f9317499 /src/gui/image/qjpeghandler.cpp
parentee9e29a9d203ed1404810aa4097bb8e0db483dda (diff)
parenteb2926a2f9607e985b8bca54346e6fdf91343247 (diff)
downloadQt-80c2e1211065f606c6f39e708a74afad1c624663.zip
Qt-80c2e1211065f606c6f39e708a74afad1c624663.tar.gz
Qt-80c2e1211065f606c6f39e708a74afad1c624663.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: (105 commits) Fixed drawing a large number of glyphs with the same font under GL. Bump version to 4.7.1. Qt headers must be included before X11 headers Fixes bezier curves not being drawn when it is a line. Avoid creating copy of an image in memory when storing as jpeg QSslSocketPrivate::systemCaCertificates() hangs sometimes on Symbian Add exception barrier to QCertificateRetriever::RunL() Reference correct declarative elements page. QtWebKit: Update tag files to match the same content on qtwebkit.git QtWebKit: Downstream patch 2 fixing a crash on MSVC 64bit. QtWebKit: Downstream patch 1 fixing a crash on MSVC 64bit. Doc: updating the qdocconf files and the stylesheet Doc: updating details on Tier 2 platforms Doc: adding remark on release of qt quick element support in creator Update configure.exe Revert "let WebKit inject itself into the qt configuration" Revert "fix qt_webkit_version.pri install for in-Qt builds" Revert "Fixed incorrect Symbian scoping." QS60Style: Itemviews are drawn incorrectly Change to commercial license headers in preparation for release. ...
Diffstat (limited to 'src/gui/image/qjpeghandler.cpp')
-rw-r--r--src/gui/image/qjpeghandler.cpp41
1 files changed, 13 insertions, 28 deletions
diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp
index e685694..b9eda05 100644
--- a/src/gui/image/qjpeghandler.cpp
+++ b/src/gui/image/qjpeghandler.cpp
@@ -515,29 +515,10 @@ inline my_jpeg_destination_mgr::my_jpeg_destination_mgr(QIODevice *device)
free_in_buffer = max_buf;
}
-static bool can_write_format(QImage::Format fmt)
-{
- switch (fmt) {
- case QImage::Format_Mono:
- case QImage::Format_MonoLSB:
- case QImage::Format_Indexed8:
- case QImage::Format_RGB888:
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- return true;
- break;
- default:
- break;
- }
- return false;
-}
-static bool write_jpeg_image(const QImage &sourceImage, QIODevice *device, int sourceQuality)
+static bool write_jpeg_image(const QImage &image, QIODevice *device, int sourceQuality)
{
bool success = false;
- const QImage image = can_write_format(sourceImage.format()) ?
- sourceImage : sourceImage.convertToFormat(QImage::Format_RGB888);
const QVector<QRgb> cmap = image.colorTable();
struct jpeg_compress_struct cinfo;
@@ -614,7 +595,7 @@ static bool write_jpeg_image(const QImage &sourceImage, QIODevice *device, int s
case QImage::Format_Mono:
case QImage::Format_MonoLSB:
if (gray) {
- const uchar* data = image.scanLine(cinfo.next_scanline);
+ const uchar* data = image.constScanLine(cinfo.next_scanline);
if (image.format() == QImage::Format_MonoLSB) {
for (int i=0; i<w; i++) {
bool bit = !!(*(data + (i >> 3)) & (1 << (i & 7)));
@@ -627,7 +608,7 @@ static bool write_jpeg_image(const QImage &sourceImage, QIODevice *device, int s
}
}
} else {
- const uchar* data = image.scanLine(cinfo.next_scanline);
+ const uchar* data = image.constScanLine(cinfo.next_scanline);
if (image.format() == QImage::Format_MonoLSB) {
for (int i=0; i<w; i++) {
bool bit = !!(*(data + (i >> 3)) & (1 << (i & 7)));
@@ -647,13 +628,13 @@ static bool write_jpeg_image(const QImage &sourceImage, QIODevice *device, int s
break;
case QImage::Format_Indexed8:
if (gray) {
- const uchar* pix = image.scanLine(cinfo.next_scanline);
+ const uchar* pix = image.constScanLine(cinfo.next_scanline);
for (int i=0; i<w; i++) {
*row = qRed(cmap[*pix]);
++row; ++pix;
}
} else {
- const uchar* pix = image.scanLine(cinfo.next_scanline);
+ const uchar* pix = image.constScanLine(cinfo.next_scanline);
for (int i=0; i<w; i++) {
*row++ = qRed(cmap[*pix]);
*row++ = qGreen(cmap[*pix]);
@@ -663,12 +644,12 @@ static bool write_jpeg_image(const QImage &sourceImage, QIODevice *device, int s
}
break;
case QImage::Format_RGB888:
- memcpy(row, image.scanLine(cinfo.next_scanline), w * 3);
+ memcpy(row, image.constScanLine(cinfo.next_scanline), w * 3);
break;
case QImage::Format_RGB32:
case QImage::Format_ARGB32:
case QImage::Format_ARGB32_Premultiplied: {
- QRgb* rgb = (QRgb*)image.scanLine(cinfo.next_scanline);
+ const QRgb* rgb = (const QRgb*)image.constScanLine(cinfo.next_scanline);
for (int i=0; i<w; i++) {
*row++ = qRed(*rgb);
*row++ = qGreen(*rgb);
@@ -678,8 +659,12 @@ static bool write_jpeg_image(const QImage &sourceImage, QIODevice *device, int s
break;
}
default:
- qWarning("QJpegHandler: unable to write image of format %i",
- image.format());
+ for (int i=0; i<w; i++) {
+ QRgb pix = image.pixel(i, cinfo.next_scanline);
+ *row++ = qRed(pix);
+ *row++ = qGreen(pix);
+ *row++ = qBlue(pix);
+ }
break;
}
jpeg_write_scanlines(&cinfo, row_pointer, 1);