Targa files with palettes and alpha #3930
Unanswered
jessey-git
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I believe the current handling of Targa files with palettes is broken in some ways. However, the spec is a bit unclear on certain things and I need advice on how to proceed with a fix.
As a reminder, the spec is here: https://www.dca.fee.unicamp.br/~martino/disciplinas/ea978/tgaffs.pdf
Issue 1
Spec:
Field 5.6 (1 byte) - Image Descriptor:
(Page 8) andAttributes Type - Field 24 (1 Byte):
(Page 17)OIIO: https://github.com/OpenImageIO/oiio/blob/master/src/targa.imageio/targainput.cpp#L225
I think there's confusion around what this byte value means. From the spec it sounds like this is the number of bits of alpha whereas OIIO wants to interpret it as the type of alpha.
In either case, the current 0x08 mask used in OIIO seems incorrect. There's nothing in the spec about using the 4th bit (0x8) to detect such things.
Paletted files will also need to be handled in the conditional as well since they support alpha just fine. However, I only have a single paletted file to play with. Does anyone have more?
Issue 2:
OIIO: https://github.com/OpenImageIO/oiio/blob/master/src/targa.imageio/targainput.cpp#L236
The
oiio:BitsPerSample
value is most likely incorrect when using paletted files. I think it needs to be something along the lines of:The paletted files I have access to seem to have
m_tga.bpp == 8
but theirm_tga.cmap_size == 32
which produces more reasonable values e.g. 8 instead of 2 bits-per-sample for a 4-channel image. But why do this division at all? Is this bits-per-channel or bits-per-pixel really?Beta Was this translation helpful? Give feedback.
All reactions