summaryrefslogtreecommitdiff
path: root/src/gui/image/qbmphandler.cpp
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-08-03 11:03:22 +0200
committerSamuel Rødal <samuel.rodal@nokia.com>2011-08-03 11:03:22 +0200
commit92c998afb66a2ec900d50cab57929c0a97ad46ac (patch)
tree1f6219dc64c236c85d7365f8e07ee1df1f27a610 /src/gui/image/qbmphandler.cpp
parent6c4dec7bff6f55b0c41729f4a4ab6962a037af15 (diff)
parent6f4212e5936b96a8be0eacddbfc4dd7ca5abd776 (diff)
downloadqtbase-92c998afb66a2ec900d50cab57929c0a97ad46ac.tar.gz
Merge remote branch 'gerrit/master' into refactor
Conflicts: src/gui/kernel/qapplication_x11.cpp src/gui/widgets/qlinecontrol.cpp src/gui/widgets/qlinecontrol_p.h src/gui/widgets/qtabwidget.h Change-Id: I90ba893a5553b9ff5658ca0a3221ecf76be4c736
Diffstat (limited to 'src/gui/image/qbmphandler.cpp')
-rw-r--r--src/gui/image/qbmphandler.cpp64
1 files changed, 55 insertions, 9 deletions
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp
index 7848bc96f3..d854b1765b 100644
--- a/src/gui/image/qbmphandler.cpp
+++ b/src/gui/image/qbmphandler.cpp
@@ -97,8 +97,10 @@ static QDataStream &operator<<(QDataStream &s, const BMP_FILEHDR &bf)
const int BMP_OLD = 12; // old Windows/OS2 BMP size
-const int BMP_WIN = 40; // new Windows BMP size
+const int BMP_WIN = 40; // Windows BMP v3 size
const int BMP_OS2 = 64; // new OS/2 BMP size
+const int BMP_WIN4 = 108; // Windows BMP v4 size
+const int BMP_WIN5 = 124; // Windows BMP v5 size
const int BMP_RGB = 0; // no compression
const int BMP_RLE8 = 1; // run-length encoded, 8 bits
@@ -109,7 +111,7 @@ const int BMP_BITFIELDS = 3; // RGB values encoded in dat
static QDataStream &operator>>(QDataStream &s, BMP_INFOHDR &bi)
{
s >> bi.biSize;
- if (bi.biSize == BMP_WIN || bi.biSize == BMP_OS2) {
+ if (bi.biSize == BMP_WIN || bi.biSize == BMP_OS2 || bi.biSize == BMP_WIN4 || bi.biSize == BMP_WIN5) {
s >> bi.biWidth >> bi.biHeight >> bi.biPlanes >> bi.biBitCount;
s >> bi.biCompression >> bi.biSizeImage;
s >> bi.biXPelsPerMeter >> bi.biYPelsPerMeter;
@@ -255,7 +257,57 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
image.setDotsPerMeterY(bi.biYPelsPerMeter);
if (!d->isSequential())
- d->seek(startpos + BMP_FILEHDR_SIZE + bi.biSize); // goto start of colormap
+ d->seek(startpos + BMP_FILEHDR_SIZE + (bi.biSize >= BMP_WIN4? BMP_WIN : bi.biSize)); // goto start of colormap
+
+ if (bi.biSize >= BMP_WIN4 || (comp == BMP_BITFIELDS && (nbits == 16 || nbits == 32))) {
+ Q_ASSERT(ncols == 0);
+
+ if (d->read((char *)&red_mask, sizeof(red_mask)) != sizeof(red_mask))
+ return false;
+ if (d->read((char *)&green_mask, sizeof(green_mask)) != sizeof(green_mask))
+ return false;
+ if (d->read((char *)&blue_mask, sizeof(blue_mask)) != sizeof(blue_mask))
+ return false;
+
+ // Read BMP v4+ header
+ if (bi.biSize >= BMP_WIN4) {
+ int alpha_mask = 0;
+ int CSType = 0;
+ int gamma_red = 0;
+ int gamma_green = 0;
+ int gamma_blue = 0;
+ int endpoints[9];
+
+ if (d->read((char *)&alpha_mask, sizeof(alpha_mask)) != sizeof(alpha_mask))
+ return false;
+ if (d->read((char *)&CSType, sizeof(CSType)) != sizeof(CSType))
+ return false;
+ if (d->read((char *)&endpoints, sizeof(endpoints)) != sizeof(endpoints))
+ return false;
+ if (d->read((char *)&gamma_red, sizeof(gamma_red)) != sizeof(gamma_red))
+ return false;
+ if (d->read((char *)&gamma_green, sizeof(gamma_green)) != sizeof(gamma_green))
+ return false;
+ if (d->read((char *)&gamma_blue, sizeof(gamma_blue)) != sizeof(gamma_blue))
+ return false;
+
+ if (bi.biSize == BMP_WIN5) {
+ qint32 intent = 0;
+ qint32 profileData = 0;
+ qint32 profileSize = 0;
+ qint32 reserved = 0;
+
+ if (d->read((char *)&intent, sizeof(intent)) != sizeof(intent))
+ return false;
+ if (d->read((char *)&profileData, sizeof(profileData)) != sizeof(profileData))
+ return false;
+ if (d->read((char *)&profileSize, sizeof(profileSize)) != sizeof(profileSize))
+ return false;
+ if (d->read((char *)&reserved, sizeof(reserved)) != sizeof(reserved) || reserved != 0)
+ return false;
+ }
+ }
+ }
if (ncols > 0) { // read color table
uchar rgb[4];
@@ -268,12 +320,6 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
return false;
}
} else if (comp == BMP_BITFIELDS && (nbits == 16 || nbits == 32)) {
- if (d->read((char *)&red_mask, sizeof(red_mask)) != sizeof(red_mask))
- return false;
- if (d->read((char *)&green_mask, sizeof(green_mask)) != sizeof(green_mask))
- return false;
- if (d->read((char *)&blue_mask, sizeof(blue_mask)) != sizeof(blue_mask))
- return false;
red_shift = calc_shift(red_mask);
red_scale = 256 / ((red_mask >> red_shift) + 1);
green_shift = calc_shift(green_mask);