aliens

Author Topic: [Answered] How to determine RGB mask in lodepng in surface loadImage  (Read 2661 times)

Offline Drago888

  • Captain
  • ***
  • Posts: 57
    • View Profile
Dear experts,

Need to seek your guidance on how lodepng does the RGB encoding for true color 24 bits pixels?
Cos when using lodepng, some of the pictures will have their color wrong, whereas most have it correct. I believe that it is caused by the endianness which strangely is different for each image. I am treating lodepng as always storing as RGB.

Also, what is the purpose of lodepng?
Cos when I use SDL_Image only, all my images will be correct color. (As I can determine endianness from SDL_BYTEORDER)

Thanks in advance
« Last Edit: February 12, 2023, 10:42:16 am by Meridian »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8597
    • View Profile
Re: How to determine RGB mask in lodepng in surface loadImage
« Reply #1 on: November 06, 2020, 12:22:14 pm »
Need to seek your guidance on how lodepng does the RGB encoding for true color 24 bits pixels?

don't know

Also, what is the purpose of lodepng?
Cos when I use SDL_Image only, all my images will be correct color. (As I can determine endianness from SDL_BYTEORDER)

The purpose of lodepng is to load PNGs correctly.
SDL_Image doesn't work correctly on all platforms, e.g. on OSX.

PS: that's also why PNGs are the only officially supported format in OXC/E, GIFs are not officially supported.

PPS: lodepng may be replaced by SDL_pnglite in the near future in OXCE (to be confirmed)
« Last Edit: November 06, 2020, 12:24:58 pm by Meridian »

Offline Drago888

  • Captain
  • ***
  • Posts: 57
    • View Profile
Re: How to determine RGB mask in lodepng in surface loadImage
« Reply #2 on: November 06, 2020, 12:47:45 pm »
Thanks Meridian.

Hmm, since my project will not be for Mac, thus will be safe to use SDL_Image.
At least until I figure out the endianness and RGB mask for lodepng.

Offline Stoddard

  • Colonel
  • ****
  • Posts: 485
  • in a fey mood
    • View Profile
    • Linux builds & stuff
Re: How to determine RGB mask in lodepng in surface loadImage
« Reply #3 on: November 06, 2020, 01:25:10 pm »
Seriously, don't use SDL_Image for pngs, it's based on an ancient libpng version and is buggy as hell.

SDL_pnglite is much better.

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: How to determine RGB mask in lodepng in surface loadImage
« Reply #4 on: November 06, 2020, 07:16:43 pm »
btw why you want load RGB image? right now OXCE support only 8bit graphics and ignore all palettes from loaded file.

Offline Drago888

  • Captain
  • ***
  • Posts: 57
    • View Profile
Re: How to determine RGB mask in lodepng in surface loadImage
« Reply #5 on: November 08, 2020, 07:45:57 am »
Seriously, don't use SDL_Image for pngs, it's based on an ancient libpng version and is buggy as hell.

SDL_pnglite is much better.

Thanks, think had found the issues for my images. Thus switching back to using lodepng for png and sdl_image for others.
However, not sure if it is pertaining to the images I am using only or will work for other images.

For all 24 bits color, lodepng is working correctly (RGB). However, 32 bits images, I wrongly assume that it is getting ARGB. Change to RGBA and seems to be getting correct color. Hopefully it will work for all.

If there is no update here, it will be working well. Else will post another message upon finding other color distortion

Offline Drago888

  • Captain
  • ***
  • Posts: 57
    • View Profile
Re: How to determine RGB mask in lodepng in surface loadImage
« Reply #6 on: November 08, 2020, 07:48:50 am »
btw why you want load RGB image? right now OXCE support only 8bit graphics and ignore all palettes from loaded file.

I am changing cutscenes and ufopaedia images to use true color 1280x800 pictures. Thus changing the codes. Had only completed cutscenes and ufopaedia craft, craft weapon, vehicle, items. Progress is way too slow than what I hope.

How good it is if I am such a good programmer as most here :(. Then will probably have completed it by now

Offline Yankes

  • Commander
  • *****
  • Posts: 3194
    • View Profile
Re: How to determine RGB mask in lodepng in surface loadImage
« Reply #7 on: November 08, 2020, 01:15:08 pm »
I could say that this will be VERY hard in OXCE, current code is optimalzied for 8bit and changing this will make only mess in code.
You probably could have bigger chances in OXC as it still use mostly native SDL surfaces.

Offline Drago888

  • Captain
  • ***
  • Posts: 57
    • View Profile
Re: How to determine RGB mask in lodepng in surface loadImage
« Reply #8 on: November 08, 2020, 05:21:40 pm »
I could say that this will be VERY hard in OXCE, current code is optimalzied for 8bit and changing this will make only mess in code.
You probably could have bigger chances in OXC as it still use mostly native SDL surfaces.

Thanks. Still the mod that I am using (Xpiratez) is running on oxce.
And really can't stand the blocky looking pictures thus embarking to modify it for my own enjoyment of the game.