The SDL_RLEACCEL flag is respected in SDL_ConvertSurface(), per the docs.
authorSam Lantinga <slouken@libsdl.org>
Sat, 29 Nov 2008 11:26:01 +0000
changeset 2807365fe1a2aad5
parent 2806 938aa47f903a
child 2808 368410632f2d
The SDL_RLEACCEL flag is respected in SDL_ConvertSurface(), per the docs.
Fixed saving BMP files of surfaces with an alpha channel.
include/SDL_surface.h
src/SDL_compat.c
src/video/SDL_bmp.c
src/video/SDL_surface.c
     1.1 --- a/include/SDL_surface.h	Sat Nov 29 11:24:18 2008 +0000
     1.2 +++ b/include/SDL_surface.h	Sat Nov 29 11:26:01 2008 +0000
     1.3 @@ -101,9 +101,7 @@
     1.4   * flags '[RGB]mask'.
     1.5   * If the function runs out of memory, it will return NULL.
     1.6   *
     1.7 - * The 'flags' tell what kind of surface to create.
     1.8 - * SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits.
     1.9 - * SDL_SRCALPHA means that the surface will be used for alpha blits.
    1.10 + * The 'flags' are obsolete and should be set to 0.
    1.11   */
    1.12  extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
    1.13      (Uint32 flags, int width, int height, int depth,
     2.1 --- a/src/SDL_compat.c	Sat Nov 29 11:24:18 2008 +0000
     2.2 +++ b/src/SDL_compat.c	Sat Nov 29 11:26:01 2008 +0000
     2.3 @@ -614,17 +614,16 @@
     2.4  SDL_Surface *
     2.5  SDL_DisplayFormat(SDL_Surface * surface)
     2.6  {
     2.7 -    SDL_Surface *converted;
     2.8 +    SDL_PixelFormat *format;
     2.9  
    2.10      if (!SDL_PublicSurface) {
    2.11          SDL_SetError("No video mode has been set");
    2.12          return NULL;
    2.13      }
    2.14 +    format = SDL_PublicSurface->format;
    2.15  
    2.16      /* Set the flags appropriate for copying to display surface */
    2.17 -    converted = SDL_ConvertSurface(surface, SDL_PublicSurface->format, 0);
    2.18 -    SDL_SetSurfaceRLE(converted, 1);
    2.19 -    return converted;
    2.20 +    return SDL_ConvertSurface(surface, format, SDL_RLEACCEL);
    2.21  }
    2.22  
    2.23  SDL_Surface *
    2.24 @@ -673,8 +672,7 @@
    2.25          break;
    2.26      }
    2.27      format = SDL_AllocFormat(32, rmask, gmask, bmask, amask);
    2.28 -    converted = SDL_ConvertSurface(surface, format, 0);
    2.29 -    SDL_SetSurfaceRLE(converted, 1);
    2.30 +    converted = SDL_ConvertSurface(surface, format, SDL_RLEACCEL);
    2.31      SDL_FreeFormat(format);
    2.32      return converted;
    2.33  }
     3.1 --- a/src/video/SDL_bmp.c	Sat Nov 29 11:24:18 2008 +0000
     3.2 +++ b/src/video/SDL_bmp.c	Sat Nov 29 11:26:01 2008 +0000
     3.3 @@ -382,26 +382,22 @@
     3.4              ) {
     3.5              surface = saveme;
     3.6          } else {
     3.7 -            SDL_Rect bounds;
     3.8 +            SDL_PixelFormat *format;
     3.9  
    3.10              /* Convert to 24 bits per pixel */
    3.11 -            surface = SDL_CreateRGBSurface(0, saveme->w, saveme->h, 24,
    3.12 +            format = SDL_AllocFormat(24,
    3.13  #if SDL_BYTEORDER == SDL_LIL_ENDIAN
    3.14 -                                           0x00FF0000, 0x0000FF00, 0x000000FF,
    3.15 +                                     0x00FF0000, 0x0000FF00, 0x000000FF,
    3.16  #else
    3.17 -                                           0x000000FF, 0x0000FF00, 0x00FF0000,
    3.18 +                                     0x000000FF, 0x0000FF00, 0x00FF0000,
    3.19  #endif
    3.20 -                                           0);
    3.21 -            if (surface != NULL) {
    3.22 -                bounds.x = 0;
    3.23 -                bounds.y = 0;
    3.24 -                bounds.w = saveme->w;
    3.25 -                bounds.h = saveme->h;
    3.26 -                if (SDL_LowerBlit(saveme, &bounds, surface, &bounds) < 0) {
    3.27 -                    SDL_FreeSurface(surface);
    3.28 +                                     0);
    3.29 +            if (format != NULL) {
    3.30 +                surface = SDL_ConvertSurface(saveme, format, 0);
    3.31 +                if (!surface) {
    3.32                      SDL_SetError("Couldn't convert image to 24 bpp");
    3.33 -                    surface = NULL;
    3.34                  }
    3.35 +                SDL_FreeFormat(format);
    3.36              }
    3.37          }
    3.38      }
     4.1 --- a/src/video/SDL_surface.c	Sat Nov 29 11:24:18 2008 +0000
     4.2 +++ b/src/video/SDL_surface.c	Sat Nov 29 11:26:01 2008 +0000
     4.3 @@ -41,6 +41,9 @@
     4.4  {
     4.5      SDL_Surface *surface;
     4.6  
     4.7 +    /* The flags are no longer used, make the compiler happy */
     4.8 +    flags;
     4.9 +
    4.10      /* Allocate the surface */
    4.11      surface = (SDL_Surface *) SDL_calloc(1, sizeof(*surface));
    4.12      if (surface == NULL) {
    4.13 @@ -754,8 +757,8 @@
    4.14   * Convert a surface into the specified pixel format.
    4.15   */
    4.16  SDL_Surface *
    4.17 -SDL_ConvertSurface(SDL_Surface * surface,
    4.18 -                   SDL_PixelFormat * format, Uint32 flags)
    4.19 +SDL_ConvertSurface(SDL_Surface * surface, SDL_PixelFormat * format,
    4.20 +                   Uint32 flags)
    4.21  {
    4.22      SDL_Surface *convert;
    4.23      Uint32 copy_flags;
    4.24 @@ -777,7 +780,7 @@
    4.25      }
    4.26  
    4.27      /* Create a new surface with the desired format */
    4.28 -    convert = SDL_CreateRGBSurface(0, surface->w, surface->h,
    4.29 +    convert = SDL_CreateRGBSurface(flags, surface->w, surface->h,
    4.30                                     format->BitsPerPixel, format->Rmask,
    4.31                                     format->Gmask, format->Bmask,
    4.32                                     format->Amask);
    4.33 @@ -827,6 +830,7 @@
    4.34      if (format->Amask || (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
    4.35          SDL_SetSurfaceBlendMode(convert, SDL_TEXTUREBLENDMODE_BLEND);
    4.36      }
    4.37 +    SDL_SetSurfaceRLE(convert, (flags & SDL_RLEACCEL));
    4.38  
    4.39      /* We're ready to go! */
    4.40      return (convert);