comparison src/video/SDL_surface.c @ 2807:365fe1a2aad5

The SDL_RLEACCEL flag is respected in SDL_ConvertSurface(), per the docs. Fixed saving BMP files of surfaces with an alpha channel.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 29 Nov 2008 11:26:01 +0000
parents 93764fe8601a
children 4dba7aa7ea77
comparison
equal deleted inserted replaced
2806:938aa47f903a 2807:365fe1a2aad5
38 SDL_CreateRGBSurface(Uint32 flags, 38 SDL_CreateRGBSurface(Uint32 flags,
39 int width, int height, int depth, 39 int width, int height, int depth,
40 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) 40 Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
41 { 41 {
42 SDL_Surface *surface; 42 SDL_Surface *surface;
43
44 /* The flags are no longer used, make the compiler happy */
45 flags;
43 46
44 /* Allocate the surface */ 47 /* Allocate the surface */
45 surface = (SDL_Surface *) SDL_calloc(1, sizeof(*surface)); 48 surface = (SDL_Surface *) SDL_calloc(1, sizeof(*surface));
46 if (surface == NULL) { 49 if (surface == NULL) {
47 SDL_OutOfMemory(); 50 SDL_OutOfMemory();
752 755
753 /* 756 /*
754 * Convert a surface into the specified pixel format. 757 * Convert a surface into the specified pixel format.
755 */ 758 */
756 SDL_Surface * 759 SDL_Surface *
757 SDL_ConvertSurface(SDL_Surface * surface, 760 SDL_ConvertSurface(SDL_Surface * surface, SDL_PixelFormat * format,
758 SDL_PixelFormat * format, Uint32 flags) 761 Uint32 flags)
759 { 762 {
760 SDL_Surface *convert; 763 SDL_Surface *convert;
761 Uint32 copy_flags; 764 Uint32 copy_flags;
762 SDL_Rect bounds; 765 SDL_Rect bounds;
763 766
775 return (NULL); 778 return (NULL);
776 } 779 }
777 } 780 }
778 781
779 /* Create a new surface with the desired format */ 782 /* Create a new surface with the desired format */
780 convert = SDL_CreateRGBSurface(0, surface->w, surface->h, 783 convert = SDL_CreateRGBSurface(flags, surface->w, surface->h,
781 format->BitsPerPixel, format->Rmask, 784 format->BitsPerPixel, format->Rmask,
782 format->Gmask, format->Bmask, 785 format->Gmask, format->Bmask,
783 format->Amask); 786 format->Amask);
784 if (convert == NULL) { 787 if (convert == NULL) {
785 return (NULL); 788 return (NULL);
825 /* Enable alpha blending by default if the new surface has an 828 /* Enable alpha blending by default if the new surface has an
826 * alpha channel or alpha modulation */ 829 * alpha channel or alpha modulation */
827 if (format->Amask || (copy_flags & SDL_COPY_MODULATE_ALPHA)) { 830 if (format->Amask || (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
828 SDL_SetSurfaceBlendMode(convert, SDL_TEXTUREBLENDMODE_BLEND); 831 SDL_SetSurfaceBlendMode(convert, SDL_TEXTUREBLENDMODE_BLEND);
829 } 832 }
833 SDL_SetSurfaceRLE(convert, (flags & SDL_RLEACCEL));
830 834
831 /* We're ready to go! */ 835 /* We're ready to go! */
832 return (convert); 836 return (convert);
833 } 837 }
834 838