mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-05-28 00:30:23 -04:00
Fix writing TGA alpha depth flag
Correctly write alpha channel depth as 8-bit.
This commit is contained in:
parent
d34c1668aa
commit
20cec27ae8
Binary file not shown.
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
@ -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++) {
|
||||
|
Loading…
Reference in New Issue
Block a user