diff --git a/autotests/write/bwa.tga b/autotests/write/bwa.tga index c0b2ab8..486aad4 100644 Binary files a/autotests/write/bwa.tga and b/autotests/write/bwa.tga differ diff --git a/autotests/write/rgba.tga b/autotests/write/rgba.tga index d1fe862..ace8015 100644 Binary files a/autotests/write/rgba.tga and b/autotests/write/rgba.tga differ diff --git a/src/imageformats/tga.cpp b/src/imageformats/tga.cpp index e067bc8..04127d2 100644 --- a/src/imageformats/tga.cpp +++ b/src/imageformats/tga.cpp @@ -430,6 +430,9 @@ bool TGAHandler::write(const QImage &image) const QImage &img = image; const bool hasAlpha = (img.format() == QImage::Format_ARGB32); + static constexpr quint8 originTopLeft = TGA_ORIGIN_UPPER + TGA_ORIGIN_LEFT; // 0x20 + static constexpr quint8 alphaChannel8Bits = 0x08; + for (int i = 0; i < 12; i++) { s << targaMagic[i]; } @@ -438,7 +441,7 @@ bool TGAHandler::write(const QImage &image) s << quint16(img.width()); // width s << quint16(img.height()); // height s << quint8(hasAlpha ? 32 : 24); // depth (24 bit RGB + 8 bit alpha) - s << quint8(hasAlpha ? 0x24 : 0x20); // top left image (0x20) + 8 bit alpha (0x4) + s << quint8(hasAlpha ? originTopLeft + alphaChannel8Bits : originTopLeft); // top left image (0x20) + 8 bit alpha (0x8) for (int y = 0; y < img.height(); y++) { for (int x = 0; x < img.width(); x++) {