Detect indexed-alpha images?

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…

a1

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?

I’d check the presence of SDL_SRCCOLORKEY in the surface flags–
Gabriel Gambetta
Mystery Studio - http://www.mysterystudio.com
Gabriel on Graphics - http://gabrielongraphics.blogspot.com

Try 1 equal sign instead of 2 :P> ----- Original Message -----

From: sdl-bounces+atrix2=cox.net@libsdl.org
[mailto:sdl-bounces+atrix2=cox.net at libsdl.org] On Behalf Of Gabriel
Sent: Sunday, February 05, 2006 11:07 AM
To: SDL Mailing List
Subject: Re: [SDL] Detect indexed-alpha images?

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?

I’d check the presence of SDL_SRCCOLORKEY in the surface flags


Gabriel Gambetta
Mystery Studio - http://www.mysterystudio.com
Gabriel on Graphics - http://gabrielongraphics.blogspot.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

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…

Hehe, yes, oops. Luckily, that’s not in the actual code itself, just a
typo in the email…

a1On 2/5/06, Alan Wolfe wrote:

Try 1 equal sign instead of 2 :stuck_out_tongue:

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.

a1

I’d check the presence of SDL_SRCCOLORKEY in the surface flags

Ah, there’s me looking at the SDL_PixelFormat and I’d mostly overlooked
the containing surface. I’ll give it a try…

cheers,
a1