| Summary: | mask for little endian not working | ||
|---|---|---|---|
| Product: | SDL | Reporter: | tim <tim> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 1.2.11 | ||
| Hardware: | x86 | ||
| OS: | Windows (95/98/ME) | ||
Endianness only matters in SDL if the surface is 24-bit. ARGB data is A-R-G-B in memory, regardless of disk layout. See SDL_bmp.c for an example of this. If you're looking at SDL_image PNG code, there's unconditional endian code in there because the PNG color channels are stored on disk in a fixed channel order, and SDL's in-memory masks have to be switched to adjust to that order at load time. |
Using the SDL_CreateSurface function when SDL_BYTEORDER is not SDL_BIG_ENDIAN normally the masks should be rmask = 0x000000ff; gmask = 0x0000ff00; bmask = 0x00ff0000; amask = 0xff000000; when creating the surface. as per the documentation example. however it does not work like this and I have to set rmask to 0x00ff0000 and bmask to 0x000000ff to get expected results. eg SDL_FillRect(pic,NULL,SDL_MapRGB(pic->format,140,0,0)); will give a blue pic, not a red one, unless I switch the mask. (pic is 16, 24 or 32 bit surface) I don't know if this is similar to bug 200, but as it is a pc AthlonXP with onboard s3 graphics i don't think so. I am using devcpp 4.9.9.2 with