Jump to content

zero alpha incompatibility with Civilization 4 TGA


Jet
 Share

Recommended Posts

Here's another compatibility problem due to PDN (3.36) not saving out color values on pixels where the alpha value is zero. I think this information is new to this board and worth your consideration, but I understand that you've discussed the issue before, and I'm not asking you to debate it further.

The incompatibility is with Civilization 4. It requires its file "GameFonts.tga" to have certain pixels with zero alpha and certain color values. (It doesn't render those pixels; it uses the color information in them for something else.) So I can't edit the file with PDN. I have to use Gimp instead.

I figure if we report enough incompatibilities, you might eventually change your mind for reasons of practicality.

A related argument in favor of changing PDN is that TGA 2.0 allows files to "abuse" the alpha channel. Granted, the place where the file specifies what it's doing with the alpha channel is [field 24 of] the Extension Area, the interpretation of which is stated to be optional. Still, there is support in the spec for the point of view that alpha need not always be interpreted strictly for rendering.

Link to comment
Share on other sites

Here's another compatibility problem due to PDN (3.36) not saving out color values on pixels where the alpha value is zero.

It's not that Paint.NET isn't saving out the color values. It's that the mathematics involved in alpha composition wipe out the color values. At some point I have to divide the color channels by the alpha channel, and it's either crash the app (bad idea obviously) or pick some value to use instead. That value is zero. I'm not changing that.

If other applications want to treat the alpha channel in a special way, that's completely their prerogative. When Paint.NET goes to open a TGA and it says "I have a normal alpha channel", then Paint.NET is going to believe it. There's no way to know that it's really some specially encoded Civilization 4 bitmap.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Here.

* It uses a background of fully transparent pixels as a delimiter to encode a set of icons in a single file. The game requires most of the delimiter pixels to be transparent magenta, except for one delimiter pixel per icon which must be transparent cyan.

* As you'll see, it doesn't contain a TGA Exended Area.

* This version is from Civilization 4 with the Beyond The Sword expansion. It's the property of Firaxis Games. I'm posting it under the terms that allow people to distribute Civ 4 mods. To be precise, the file name is GameFont.tga rather than GameFonts.tga as I said in the OP.

GameFont-tga.zip

Link to comment
Share on other sites

(Edited to make my point a different way.)

It's not that Paint.NET isn't saving out the color values. It's that the mathematics involved in alpha composition wipe out the color values. At some point I have to divide the color channels by the alpha channel, and it's either crash the app (bad idea obviously) or pick some value to use instead. That value is zero. I'm not changing that.

I understand that you have an elegance motivation not to change it and possibly also a performance motivation; I read that in some of the earlier threads. I don't think it's constructive for you and I to debate your engineering tradeoffs as a whole. Where I think I can make an effective contribution is by providing new information and perspectives which add to your understanding of the tradeoffs.

That said, I don't appreciate your using language implying that you have no choice. The rendering mathematics only force you to throw out the information you read from the TGA file when you're rendering it to the screen, not in the representation that you use to save the data to disk. Your appeal to mathematics per se is an unfair argument.

There's no way to know that it's really some specially encoded Civilization 4 bitmap.

That is true for this file, but not in general. There is a way. The file could have had an extension area whose field 24 contained the value 2, meaning "undefined data in the Alpha field, but should be retained".

Link to comment
Share on other sites

That said, I don't appreciate your using language implying that you have no choice.

You don't have to appreciate it. The code used to render to the screen is the same used to prepare the bitmap for the Save() code.

Stop arguing with me. I don't appreciate that.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...