Fixed bug 3309 - SDL_ConvertSurface adds AlphaMod when input surface has ColorKey
authorSam Lantinga
Sat, 12 Aug 2017 15:21:26 -0700
changeset 112461667e6dafc85
parent 11245 283194179512
child 11247 27eb9a10002c
Fixed bug 3309 - SDL_ConvertSurface adds AlphaMod when input surface has ColorKey

Sylvain

Let's you have a SDL_Surface that has ColorKey, but no Alpha Modulation.
When this surface is duplicated with SDL_ConvertSurface function, the result has ColorKey and Alpha Modulation (BLEND, and Opaque 255).

I think SDL_ConvertSurface should strictly keeps the input format.


example
=======

SDL_Surface *input; // ... Set up a surface with ColorKey and no AlphaMod

SDL_Surface *output = SDL_ConvertSurface(input, input->format, input->flags);

// "output" surface has a ColorKey but *also* AlphaMod (BLEND, and Opaque 255).
src/video/SDL_surface.c
     1.1 --- a/src/video/SDL_surface.c	Sat Aug 12 15:00:33 2017 -0700
     1.2 +++ b/src/video/SDL_surface.c	Sat Aug 12 15:21:26 2017 -0700
     1.3 @@ -986,7 +986,7 @@
     1.4      /* Enable alpha blending by default if the new surface has an
     1.5       * alpha channel or alpha modulation */
     1.6      if ((surface->format->Amask && format->Amask) ||
     1.7 -        (copy_flags & (SDL_COPY_COLORKEY|SDL_COPY_MODULATE_ALPHA))) {
     1.8 +        (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
     1.9          SDL_SetSurfaceBlendMode(convert, SDL_BLENDMODE_BLEND);
    1.10      }
    1.11      if ((copy_flags & SDL_COPY_RLE_DESIRED) || (flags & SDL_RLEACCEL)) {