comparison src/video/SDL_bmp.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 c121d94672cb
children 15e1dd1fff78
comparison
equal deleted inserted replaced
2806:938aa47f903a 2807:365fe1a2aad5
380 (saveme->format->Bmask == 0x00FF0000) 380 (saveme->format->Bmask == 0x00FF0000)
381 #endif 381 #endif
382 ) { 382 ) {
383 surface = saveme; 383 surface = saveme;
384 } else { 384 } else {
385 SDL_Rect bounds; 385 SDL_PixelFormat *format;
386 386
387 /* Convert to 24 bits per pixel */ 387 /* Convert to 24 bits per pixel */
388 surface = SDL_CreateRGBSurface(0, saveme->w, saveme->h, 24, 388 format = SDL_AllocFormat(24,
389 #if SDL_BYTEORDER == SDL_LIL_ENDIAN 389 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
390 0x00FF0000, 0x0000FF00, 0x000000FF, 390 0x00FF0000, 0x0000FF00, 0x000000FF,
391 #else 391 #else
392 0x000000FF, 0x0000FF00, 0x00FF0000, 392 0x000000FF, 0x0000FF00, 0x00FF0000,
393 #endif 393 #endif
394 0); 394 0);
395 if (surface != NULL) { 395 if (format != NULL) {
396 bounds.x = 0; 396 surface = SDL_ConvertSurface(saveme, format, 0);
397 bounds.y = 0; 397 if (!surface) {
398 bounds.w = saveme->w;
399 bounds.h = saveme->h;
400 if (SDL_LowerBlit(saveme, &bounds, surface, &bounds) < 0) {
401 SDL_FreeSurface(surface);
402 SDL_SetError("Couldn't convert image to 24 bpp"); 398 SDL_SetError("Couldn't convert image to 24 bpp");
403 surface = NULL;
404 } 399 }
400 SDL_FreeFormat(format);
405 } 401 }
406 } 402 }
407 } 403 }
408 404
409 if (surface && (SDL_LockSurface(surface) == 0)) { 405 if (surface && (SDL_LockSurface(surface) == 0)) {