[SDL] PNG Transparency (other image formats too)

Laurent Carlier lordheavy at infonie.fr
Thu Sep 28 13:50:52 PDT 2006


Le jeudi 28 septembre 2006 22:36, mal content a écrit :
> On 28/09/06, mal content <artifact.one at googlemail.com> wrote:
> > On 28/09/06, David Olofson <david at olofson.net> wrote:
> > > SDL_DisplayFormatAlpha()
> >
> > On 28/09/06, Torsten Giebl <wizard at syntheticsw.com> wrote:
> > > There is a SDL_DisplayFormatAlpha(), just test this.
>
> Ok, I have another one...
>
> What's a reliable way to test if a freshly loaded image has an
> alpha channel, so I know whether to call SDL_DisplayFormatAlpha()
> or just plain SDL_DisplayFormat() on it?
>
> MC
>

Check for the SDL_SRCALPHA flag of the loaded surface :-)

something like :

if (surface->flags & SDL_SRCALPHA)
  surface = SDL_DisplayFormatAlpha(surface);
else
  surface = SDL_DisplayFormat(surface);

++





More information about the SDL mailing list