diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-15 09:10:02 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-15 09:10:02 +0200 |
commit | 5b1a3318125b72563b5de1bf7549088165ec60f4 (patch) | |
tree | 1aec8465db302fc7228cfd060d6ee132a99a69bd /src | |
parent | c3035a1655090b0f6b194fb8a7586c013ef24f6a (diff) | |
parent | 98f83553e9fe2aa5fc54b32513af6ba3aa60a07b (diff) |
Merge remote-tracking branch 'origin/5.4' into 5.5v5.5.0-beta1
Change-Id: Ib6f1512a15f2714a712ff82df55a9d3de8e46ffd
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/imageformats/dds/qddshandler.cpp | 4 | ||||
-rw-r--r-- | src/plugins/imageformats/tiff/qtiffhandler.cpp | 23 |
2 files changed, 8 insertions, 19 deletions
diff --git a/src/plugins/imageformats/dds/qddshandler.cpp b/src/plugins/imageformats/dds/qddshandler.cpp index 9d44f26..50ac67c 100644 --- a/src/plugins/imageformats/dds/qddshandler.cpp +++ b/src/plugins/imageformats/dds/qddshandler.cpp @@ -103,7 +103,7 @@ struct FormatInfo static const FormatInfo formatInfos[] = { { FormatA8R8G8B8, DDSPixelFormat::FlagRGBA, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }, { FormatX8R8G8B8, DDSPixelFormat::FlagRGB, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 }, - { FormatA2B10G10R10, DDSPixelFormat::FlagRGBA, 32, 0x000003ff, 0x0000fc00, 0x3ff00000, 0xc0000000 }, + { FormatA2B10G10R10, DDSPixelFormat::FlagRGBA, 32, 0x000003ff, 0x000ffc00, 0x3ff00000, 0xc0000000 }, { FormatA8B8G8R8, DDSPixelFormat::FlagRGBA, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }, { FormatX8B8G8R8, DDSPixelFormat::FlagRGB, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000 }, { FormatG16R16, DDSPixelFormat::FlagRGBA, 32, 0x0000ffff, 0xffff0000, 0x00000000, 0x00000000 }, @@ -325,7 +325,7 @@ static Format getFormat(const DDSHeader &dds) if ((format.flags & info.flags) == info.flags && format.rgbBitCount == info.bitCount && format.rBitMask == info.rBitMask && - format.bBitMask == info.bBitMask && + format.gBitMask == info.gBitMask && format.bBitMask == info.bBitMask && format.aBitMask == info.aBitMask) { return info.format; diff --git a/src/plugins/imageformats/tiff/qtiffhandler.cpp b/src/plugins/imageformats/tiff/qtiffhandler.cpp index f7151f7..71b2ccc 100644 --- a/src/plugins/imageformats/tiff/qtiffhandler.cpp +++ b/src/plugins/imageformats/tiff/qtiffhandler.cpp @@ -494,20 +494,13 @@ bool QTiffHandler::write(const QImage &image) } //// write the color table // allocate the color tables - uint16 *redTable = static_cast<uint16 *>(malloc(256 * sizeof(uint16))); - uint16 *greenTable = static_cast<uint16 *>(malloc(256 * sizeof(uint16))); - uint16 *blueTable = static_cast<uint16 *>(malloc(256 * sizeof(uint16))); - if (!redTable || !greenTable || !blueTable) { - free(redTable); - free(greenTable); - free(blueTable); - TIFFClose(tiff); - return false; - } - - // set the color table const int tableSize = colorTable.size(); Q_ASSERT(tableSize <= 256); + QVarLengthArray<uint16> redTable(tableSize); + QVarLengthArray<uint16> greenTable(tableSize); + QVarLengthArray<uint16> blueTable(tableSize); + + // set the color table for (int i = 0; i<tableSize; ++i) { const QRgb color = colorTable.at(i); redTable[i] = qRed(color) * 257; @@ -515,11 +508,7 @@ bool QTiffHandler::write(const QImage &image) blueTable[i] = qBlue(color) * 257; } - const bool setColorTableSuccess = TIFFSetField(tiff, TIFFTAG_COLORMAP, redTable, greenTable, blueTable); - - free(redTable); - free(greenTable); - free(blueTable); + const bool setColorTableSuccess = TIFFSetField(tiff, TIFFTAG_COLORMAP, redTable.data(), greenTable.data(), blueTable.data()); if (!setColorTableSuccess) { TIFFClose(tiff); |