summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorABBAPOH <ABBAPOH@nextmail.ru>2013-12-01 12:47:53 +0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-02 09:51:20 +0100
commit65fa7497f2561d30a3e82668f9fc29fa6f789a8d (patch)
treec2531019501ba280b09ed11ab5f7c1d82e429528 /src
parenta5f8d2544def6aaad020ac3a8c8297295eeb2407 (diff)
Fix writing images in DDS handler
Change-Id: If433528eb4cfa7448f171e083dd2bb559dbc2f4a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/imageformats/dds/qddshandler.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/plugins/imageformats/dds/qddshandler.cpp b/src/plugins/imageformats/dds/qddshandler.cpp
index 8dd5ed3..01a8782 100644
--- a/src/plugins/imageformats/dds/qddshandler.cpp
+++ b/src/plugins/imageformats/dds/qddshandler.cpp
@@ -1266,18 +1266,19 @@ bool QDDSHandler::read(QImage *outImage)
bool QDDSHandler::write(const QImage &outImage)
{
- QDataStream s( device() );
+ const QImage image = outImage.convertToFormat(QImage::Format_ARGB32);
+
+ QDataStream s(device());
s.setByteOrder(QDataStream::LittleEndian);
- // Filling header
DDSHeader dds;
// Filling header
dds.magic = ddsMagic;
dds.size = 124;
dds.flags = DDSHeader::FlagCaps | DDSHeader::FlagHeight |
DDSHeader::FlagWidth | DDSHeader::FlagPixelFormat;
- dds.height = outImage.height();
- dds.width = outImage.width();
+ dds.height = image.height();
+ dds.width = image.width();
dds.pitchOrLinearSize = 128;
dds.depth = 0;
dds.mipMapCount = 0;
@@ -1300,9 +1301,9 @@ bool QDDSHandler::write(const QImage &outImage)
dds.pixelFormat.bBitMask = 0x000000ff;
s << dds;
- for (int width = 0; width < outImage.width(); width++) {
- for (int height = 0; height < outImage.height(); height++) {
- QRgb pixel = outImage.pixel(height, width);;
+ for (int width = 0; width < image.width(); width++) {
+ for (int height = 0; height < image.height(); height++) {
+ QRgb pixel = image.pixel(height, width);;
quint32 color;
quint8 alpha = qAlpha(pixel);
quint8 red = qRed(pixel);