How can I reliably detect if an image loaded with IMG_Load is in indexed-alpha
format? I am loading surfaces into OpenGL, so it’s important to be able to
detect 100%.
As I see it, the following test is enough to detect RGBA images over RGB:
SDL_PixelFormat *fmt;
if (fmt->Ashift && fmt->Amask) {
type == RGBA;
} else {
type == RGB;
}
The following is enough to test for 8 bit indexed images[1]:
if (fmt->BitsPerPixel == 8) {
type == INDEXED;
}
But how can I test for indexed alpha?
if (fmt->colorkey) {
type == INDEXED_ALPHA;
}
…won’t work, as colorkey can be set to 0 for indexed-alpha images
anyway. The same sort of situation applies to fmt->alpha as far as
I can tell.
Anybody got any ideas?
a1
[1] Possibly over greyscale, although I haven’t checked to see if greyscale
images have a non-NULL ‘palette’ member.
How can I reliably detect if an image loaded with IMG_Load is in indexed-alpha
format? I am loading surfaces into OpenGL, so it’s important to be able to
detect 100%.
Hmm, this is a bit of an oversight isn’t it? Is there any way this
could be rectified
in SDL 1.3? Having tried a number of approaches, there seems to be no way
to distinguish two indexed PNG files, one with alpha and one without. This is
very bad as it pretty much cripples the OpenGL texture manager that I’ve been
trying to get finished…
Coerce your artists to set the colorkey non-zero for indexed alpha
images. Of course, this only works if you have some control over what
images will be loaded…On 2/5/06, mal content <artifact.one at googlemail.com> wrote:
How can I reliably detect if an image loaded with IMG_Load is in indexed-alpha
format? I am loading surfaces into OpenGL, so it’s important to be able to
detect 100%.
Hmm, this is a bit of an oversight isn’t it? Is there any way this
could be rectified
in SDL 1.3? Having tried a number of approaches, there seems to be no way
to distinguish two indexed PNG files, one with alpha and one without. This is
very bad as it pretty much cripples the OpenGL texture manager that I’ve been
trying to get finished…
Coerce your artists to set the colorkey non-zero for indexed alpha
images. Of course, this only works if you have some control over what
images will be loaded…
I do have control over the loaded images, but unfortunately the program
being used to create them (GIMP) doesn’t seem to provide a means to
do this.