The SDL_RLEACCEL flag is respected in SDL_ConvertSurface(), per the docs.
Fixed saving BMP files of surfaces with an alpha channel. --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403268
This commit is contained in:
parent
7a4a712978
commit
fb253660b5
4 changed files with 21 additions and 25 deletions
|
@ -101,9 +101,7 @@ typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
|
||||||
* flags '[RGB]mask'.
|
* flags '[RGB]mask'.
|
||||||
* If the function runs out of memory, it will return NULL.
|
* If the function runs out of memory, it will return NULL.
|
||||||
*
|
*
|
||||||
* The 'flags' tell what kind of surface to create.
|
* The 'flags' are obsolete and should be set to 0.
|
||||||
* SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits.
|
|
||||||
* SDL_SRCALPHA means that the surface will be used for alpha blits.
|
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
|
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
|
||||||
(Uint32 flags, int width, int height, int depth,
|
(Uint32 flags, int width, int height, int depth,
|
||||||
|
|
|
@ -614,17 +614,16 @@ SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value)
|
||||||
SDL_Surface *
|
SDL_Surface *
|
||||||
SDL_DisplayFormat(SDL_Surface * surface)
|
SDL_DisplayFormat(SDL_Surface * surface)
|
||||||
{
|
{
|
||||||
SDL_Surface *converted;
|
SDL_PixelFormat *format;
|
||||||
|
|
||||||
if (!SDL_PublicSurface) {
|
if (!SDL_PublicSurface) {
|
||||||
SDL_SetError("No video mode has been set");
|
SDL_SetError("No video mode has been set");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
format = SDL_PublicSurface->format;
|
||||||
|
|
||||||
/* Set the flags appropriate for copying to display surface */
|
/* Set the flags appropriate for copying to display surface */
|
||||||
converted = SDL_ConvertSurface(surface, SDL_PublicSurface->format, 0);
|
return SDL_ConvertSurface(surface, format, SDL_RLEACCEL);
|
||||||
SDL_SetSurfaceRLE(converted, 1);
|
|
||||||
return converted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Surface *
|
SDL_Surface *
|
||||||
|
@ -673,8 +672,7 @@ SDL_DisplayFormatAlpha(SDL_Surface * surface)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
format = SDL_AllocFormat(32, rmask, gmask, bmask, amask);
|
format = SDL_AllocFormat(32, rmask, gmask, bmask, amask);
|
||||||
converted = SDL_ConvertSurface(surface, format, 0);
|
converted = SDL_ConvertSurface(surface, format, SDL_RLEACCEL);
|
||||||
SDL_SetSurfaceRLE(converted, 1);
|
|
||||||
SDL_FreeFormat(format);
|
SDL_FreeFormat(format);
|
||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
|
|
|
@ -382,26 +382,22 @@ SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst)
|
||||||
) {
|
) {
|
||||||
surface = saveme;
|
surface = saveme;
|
||||||
} else {
|
} else {
|
||||||
SDL_Rect bounds;
|
SDL_PixelFormat *format;
|
||||||
|
|
||||||
/* Convert to 24 bits per pixel */
|
/* Convert to 24 bits per pixel */
|
||||||
surface = SDL_CreateRGBSurface(0, saveme->w, saveme->h, 24,
|
format = SDL_AllocFormat(24,
|
||||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||||
0x00FF0000, 0x0000FF00, 0x000000FF,
|
0x00FF0000, 0x0000FF00, 0x000000FF,
|
||||||
#else
|
#else
|
||||||
0x000000FF, 0x0000FF00, 0x00FF0000,
|
0x000000FF, 0x0000FF00, 0x00FF0000,
|
||||||
#endif
|
#endif
|
||||||
0);
|
0);
|
||||||
if (surface != NULL) {
|
if (format != NULL) {
|
||||||
bounds.x = 0;
|
surface = SDL_ConvertSurface(saveme, format, 0);
|
||||||
bounds.y = 0;
|
if (!surface) {
|
||||||
bounds.w = saveme->w;
|
|
||||||
bounds.h = saveme->h;
|
|
||||||
if (SDL_LowerBlit(saveme, &bounds, surface, &bounds) < 0) {
|
|
||||||
SDL_FreeSurface(surface);
|
|
||||||
SDL_SetError("Couldn't convert image to 24 bpp");
|
SDL_SetError("Couldn't convert image to 24 bpp");
|
||||||
surface = NULL;
|
|
||||||
}
|
}
|
||||||
|
SDL_FreeFormat(format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,9 @@ SDL_CreateRGBSurface(Uint32 flags,
|
||||||
{
|
{
|
||||||
SDL_Surface *surface;
|
SDL_Surface *surface;
|
||||||
|
|
||||||
|
/* The flags are no longer used, make the compiler happy */
|
||||||
|
flags;
|
||||||
|
|
||||||
/* Allocate the surface */
|
/* Allocate the surface */
|
||||||
surface = (SDL_Surface *) SDL_calloc(1, sizeof(*surface));
|
surface = (SDL_Surface *) SDL_calloc(1, sizeof(*surface));
|
||||||
if (surface == NULL) {
|
if (surface == NULL) {
|
||||||
|
@ -754,8 +757,8 @@ SDL_UnlockSurface(SDL_Surface * surface)
|
||||||
* Convert a surface into the specified pixel format.
|
* Convert a surface into the specified pixel format.
|
||||||
*/
|
*/
|
||||||
SDL_Surface *
|
SDL_Surface *
|
||||||
SDL_ConvertSurface(SDL_Surface * surface,
|
SDL_ConvertSurface(SDL_Surface * surface, SDL_PixelFormat * format,
|
||||||
SDL_PixelFormat * format, Uint32 flags)
|
Uint32 flags)
|
||||||
{
|
{
|
||||||
SDL_Surface *convert;
|
SDL_Surface *convert;
|
||||||
Uint32 copy_flags;
|
Uint32 copy_flags;
|
||||||
|
@ -777,7 +780,7 @@ SDL_ConvertSurface(SDL_Surface * surface,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a new surface with the desired format */
|
/* Create a new surface with the desired format */
|
||||||
convert = SDL_CreateRGBSurface(0, surface->w, surface->h,
|
convert = SDL_CreateRGBSurface(flags, surface->w, surface->h,
|
||||||
format->BitsPerPixel, format->Rmask,
|
format->BitsPerPixel, format->Rmask,
|
||||||
format->Gmask, format->Bmask,
|
format->Gmask, format->Bmask,
|
||||||
format->Amask);
|
format->Amask);
|
||||||
|
@ -827,6 +830,7 @@ SDL_ConvertSurface(SDL_Surface * surface,
|
||||||
if (format->Amask || (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
|
if (format->Amask || (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
|
||||||
SDL_SetSurfaceBlendMode(convert, SDL_TEXTUREBLENDMODE_BLEND);
|
SDL_SetSurfaceBlendMode(convert, SDL_TEXTUREBLENDMODE_BLEND);
|
||||||
}
|
}
|
||||||
|
SDL_SetSurfaceRLE(convert, (flags & SDL_RLEACCEL));
|
||||||
|
|
||||||
/* We're ready to go! */
|
/* We're ready to go! */
|
||||||
return (convert);
|
return (convert);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue