aliens

Author Topic: [Solved] warning about transparent color index?  (Read 4913 times)

Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
[Solved] warning about transparent color index?
« on: September 13, 2019, 06:42:32 pm »
When using this mod https://openxcom.org/forum/index.php/topic,1628.0.html I encountered a strange thing. The game gives this warning:

Code: [Select]
[13-09-2019_18-23-23] [WARN] Image Resources/Retaliator/retaliator_base.gif (from SDL) have set incorrect transparent color index 255 instead of 0

But in-game this image is displayed with correct colors. However, if I fix this image so that the game does not complain about it having incorrect colors, then it's displayed with wrong colors!

I may be wrong, but it seems like a bug to me, since the game has no problem with the file it gives a warning about, and it actually does have issues with the file with no warnings.

If it's something on my side, could someone please tell me how to get rid of this warning? (Because extra warnings catch the eye when you are trying to debug something you are working on, so it bothers me).

I'm going to attach the original gif, "fixed" gif, and the screenshot of what it looks like with the "fixed" gif.
« Last Edit: February 11, 2023, 06:49:28 pm by Meridian »

Offline krautbernd

  • Commander
  • *****
  • Posts: 1108
    • View Profile
Re: Incorrect warning?
« Reply #1 on: September 13, 2019, 06:53:24 pm »
If you check your 'fixed' gif you'll notice that it's not using a valid palette - you've simply reduced the palette down to the used colors, while xcom uses 256-color indexed palettes. You're also using 5 bits per pixel instead of 8. Which is why you get garbled colors.

X-COM normally uses the color at index 0 for transparency, while this image uses index 255. You can get rid of this warning and the garbled colors by using the correct palette and using the right color index for transparency.

The reason your supposedly 'fixed' version doesn't throw any errors is simply because it uses the right index for transparency.

That aside, the game has no way to check whether or not the images your using are displayed 'the right way' (i.e. with the correct colors) - how should it be able to do that?
« Last Edit: September 13, 2019, 07:02:50 pm by krautbernd »

Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Re: Incorrect warning?
« Reply #2 on: September 13, 2019, 07:01:50 pm »
Well, I know very little about editing graphics, so I simply put the original file through

Code: [Select]
convert retaliator_minimised.gif -transparent black 1.gif

What would be the correct way of fixing the image? (Preferrably, through command line).

Offline krautbernd

  • Commander
  • *****
  • Posts: 1108
    • View Profile
Re: Incorrect warning?
« Reply #3 on: September 13, 2019, 07:22:12 pm »
Well, I know very little about editing graphics, so I simply put the original file through

Code: [Select]
convert retaliator_minimised.gif -transparent black 1.gif

What would be the correct way of fixing the image? (Preferrably, through command line).
That command doesn't tell me anything, since you've failed to state what program you're using. I normally work with GIMP, but i don't use it in batch mode.

Again, you need to use a correct palette and the correct transparency index. I'd suggest looking those up in the documentation of whatever program you're using.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3366
    • View Profile
Re: Incorrect warning?
« Reply #4 on: September 13, 2019, 07:53:43 pm »
krautbernd is correct.

In reality game ignore ALL colors you assigned in graphic. Only take index values of pixels.
If you use correct tool (like GrafX2 or other that palette graphic is first class citizen) you can analyze palette and see what pixel have what index.

Currently OXCE always is using index 0 as transparent color, even if you image say other wise. If game detects something like this, it will set all pixels of this "transparent" colors to 0 and issue warning you see.

In some far future this automatic correction will be removed and only pixels of index 0 will be used as transparency even if image say something else.

Offline krautbernd

  • Commander
  • *****
  • Posts: 1108
    • View Profile
Re: Incorrect warning?
« Reply #5 on: September 13, 2019, 08:00:39 pm »
Trippy.

Offline Kzer-Za

  • Colonel
  • ****
  • Posts: 140
    • View Profile
Re: Incorrect warning?
« Reply #6 on: September 13, 2019, 08:27:56 pm »
Sorry, I didn't think to mention that `convert` is a part of ImageMagick. I don't know what is correct palette or the correct transparency index, I just made a search on auto correcting transparency in a gif file, and this command seemed to do the trick in the sense that the engine stopped giving a warning. Since there seems to be no simple way of autochanging the transparency color while preserving other colors, I'm gonna just stick with with the acid-colored picture without warnings.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3366
    • View Profile
Re: Incorrect warning?
« Reply #7 on: September 13, 2019, 08:44:27 pm »
Trippy.
funny thing is if you load this image to OXCE it will be not trippy but normal looking :>

Overall I forget to add description why I added this image :) This was raw screenshot from game that have changed colors compared to default palette but it still same image for OXCE. becasue It only look on indexes not colors defined in image.

Online Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11759
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: Incorrect warning?
« Reply #8 on: September 15, 2019, 12:29:45 pm »
I don't know what is correct palette or the correct transparency index

How about this groundbreaking idea: take a picture which is known to work and use the same palette? :P

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9124
    • View Profile
Re: Incorrect warning?
« Reply #9 on: September 15, 2019, 12:37:49 pm »
I don't know what is correct palette or the correct transparency index

Correct palettes are here: https://github.com/MeridianOXC/OpenXcom/tree/oxce-plus/bin/common/Palettes

And correct transparency index is 0.