Talk:Image Formats

From Custom Mario Kart
Jump to navigation Jump to search

Blocks

Can anyone explain the meaning of "block size"? What is a block and for what are blocks used?
Wiimm 20:38, 18 June 2011 (CEST)

It's explained a little at the top of the format section. Basically, rather than encoding pixels in the order left to right, top to bottom, it goes left to right for the block width, then top to bottom for the block height, then does the next blocks in a left to right, top to bottom order. Example
It looks like this on screen
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
But if the block size was 2x2 it would be encoded as 1, 2, 5, 6, 3, 4, 7, 8, 9, 10, 13, 14, 11, 12, 15, 16.
Chadderz 08:59, 19 June 2011 (CEST)
Ohh, that's the reason that I see garbage in my png export. Thanx.
Wiimm 09:53, 19 June 2011 (CEST)

Byte Formats

I have some more questions about interpreting the bytes. Perhaps I can solve them by myself, but hints are welcome.

  1. I4: Is the high or low nibble (=4 bits) used for the first pixel?
  2. I4 (and some other formats): The text says: "multiply with 0x10 to get the color value". The result are values between 0x00..0xf0. Why not using the usual factor 0x11 (range 0x00..0xff)?
  3. Some formats: There are multiply factors given to find RGB+Alpha values. Are this factors based on the correct endian (most big endian)? Or on intel format (little endian)?
  4. What is the alpha channel: opacity or transparency? (I think opacity)

Wiimm 10:39, 19 June 2011 (CEST)

  1. High then low
  2. You're quite right, my mistake it should be 0x11. The old SZS Mod implementation was 0x10 due to a mistake, and I was just mindlessly copying.
  3. I'm not quite sure what you mean. Mario Kart Wii is always big endian.
  4. Generally the two are considered synonymous in this context but yes, 0xff is fully opaque, and 0x00 is fully transparent.
Chadderz 21:39, 19 June 2011 (CEST)
Thanx again. I have already implemented I4, I8, IA4 and IA8 conversions to PNG, the others will follow. In the moment, TEX0 and BREFT subfiles are converted, hooks for other formats are easy.
Point 3 was a thinking error of me. Point 4: You described opacity. If the alpha channel is "transparency" then 0x00 is fully opaque, and 0xff is fully transparent. Both are valid definitions and (but not sure) PNG and other image formats support both.
Wiimm 22:53, 19 June 2011 (CEST)
The trickiest format to implement is the CMPR, I found looking at someone else's source code the most helpful for seeing how it actually works, it's hard to describe.
On point 4, I've never heard that distinction made before, I've only ever seen formats which call 0xff opaque, and 0x00 transparent, whether they call it opacity or transparency. I'll be more specific in future though.
Chadderz 07:58, 20 June 2011 (CEST)
libpng support both kinds of alpha channel: "PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity to transparency" But I think, it's only the interface and not the png file itself that supports inverting.
Hanno 08:53, 20 June 2011 (CEST)