Opened 5 years ago
Closed 5 years ago
Last modified 5 years ago
#69 closed defect (fixed)
Loading .ICO wrong image on Big endian Mac
|Reported by:||Thomas Bernard||Owned by:||Thomas Bernard|
Everything works well on My PC, but the colors are wrong if I load a .ICO file on my PowerPC Mac.
I suspect a bug in loading little endian stuff on a big endian machine
Change History (12)
by , 5 years ago
comment:1 by , 5 years ago
|Status:||new → accepted|
|Version:||2.4 → 2.5WIP|
comment:2 by , 5 years ago
in fact it is loaded via Load_SDL_Image() so SDL IMG_Load()
comment:3 by , 5 years ago
When I ported GrafX2 from DOS I was using a PowerPC machine, so back then I found and fixed a lot of these problems. But I have not tested this in a while and I currently don't have a machine where I can easily test it (maybe an Amiga 4000 or an old PPC based X terminal which can run NetBSD...)
Anyways, it seems that Get_SDL_pixel_hicolor is doing strange things. It uses an hardcoded SDL_LIL_ENDIAN test for 24bit data and nothing for 32bit. Isn't there a better way to do this depending on the SDL_Surface format? Especially as we are shifting things again after using that function.
Either Get_SDL_pixel_hicolor should return a T_Components, or it should return an uint32_t without any bitswapping, and we should use the SDL_Surface format to decode that. But not both.
comment:4 by , 5 years ago
well it looks like a bug in SDL code to load ICO because loading another format with SDL works (color TIFF file)
comment:5 by , 5 years ago
|Summary:||Loading .ICO wrong image on Big endian machine → Loading .ICO wrong image on Big endian Mac|
I think the problem lies in SDL_Image,
ICO files are read with system loader, but probably wrongly converted...
comment:6 by , 5 years ago
Get_SDL_pixel_hicolor does different things for 24-bit and 32-bit images and ignores the pixel format given by SDL_Image (in the SDL_Surface "format" field). We should check this code very carefully to make sure there isn't a problem (the fact that Get_SDL_pixel_hicolor does endian-swap for 24 but not 32bit images makes no sense, so we very likely have a problem here). When our code is perfectly clean we can go up to SDL_Image.
comment:7 by , 5 years ago
Well I made a minimal test tool for IMG_Load()
and it wrongly shows the .ICO file, so I'm sure there is a bug in SDL Image on Mac
by , 5 years ago
sdl_image_test result on a PowerPC Mac OS X 10.4.11
comment:8 by , 5 years ago
I reorganized a bit the Load_BMP() and Load_PNG() code and added ICO image loading :
comment:9 by , 5 years ago
|Status:||accepted → closed|
comment:10 by , 5 years ago
Fixed by :
- implementing ICO loading instead of using SDL bugged (on OS X) code.
- fixing the BMP code on big endian machines
gfx2.ico loaded on a big endian machine