[SDL] Difference between a 1-bit image and an indexed image when loaded into surface

mal content artifact.one at googlemail.com
Thu Feb 15 18:47:55 PST 2007


Hi.

I'm writing a bit of code to convert SDL_Surface structures into OpenGL
textures.

Is it possible to programmatically tell the difference between:

  - 1-bit monochrome image
  - 1-bit monochrome image with alpha
  - indexed image
  - indexed image with alpha

The last two, I can distinguish between with:

   if (images[ind].img->flags & SDL_SRCCOLORKEY)
    gltxload.flags |= GLTEX_ALPHA;

So that's not a problem, but how can I tell the difference between
an indexed or monochrome image? The 'file' utility can tell for PNGs,
so at least for PNG files the images are structurally distinct:

IMAGES/1bit_alpha.png:      PNG image data, 128 x 128, 1-bit colormap,
non-interlaced
IMAGES/1bit_noalpha.png:    PNG image data, 128 x 128, 1-bit colormap,
non-interlaced
IMAGES/indexed.png:         PNG image data, 128 x 128, 2-bit colormap,
non-interlaced
IMAGES/indexed_alpha.png:   PNG image data, 128 x 128, 2-bit colormap,
non-interlaced

The point of this exercise is that I want to be able to load 1 bit
images into OpenGL as (memory) efficiently as possible, for things
such as bitmap fonts. The color can obviously be set at load time.

Any help would be appreciated.
MC


More information about the SDL mailing list