From 0c1ef3f59452e356a5e744960287331dd93b2adf Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 25 Feb 2004 05:03:13 +0000 Subject: [PATCH] SDL surfaces don't get along with const (grr) don't make assumptions about the format of the input surface --- stepmania/src/SDL_SaveJPEG.cpp | 10 +++++++++- stepmania/src/SDL_SaveJPEG.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/stepmania/src/SDL_SaveJPEG.cpp b/stepmania/src/SDL_SaveJPEG.cpp index 0a23ee348d..7bc7932e28 100644 --- a/stepmania/src/SDL_SaveJPEG.cpp +++ b/stepmania/src/SDL_SaveJPEG.cpp @@ -1,5 +1,6 @@ #include "global.h" #include "SDL.h" +#include "SDL_utils.h" #undef FAR /* fix for VC */ namespace jpeg @@ -109,8 +110,13 @@ static void jpeg_SDL_RW_dest(jpeg::j_compress_ptr cinfo, SDL_RWops *ctx) } /* Save a JPEG to a file. cjpeg.c and example.c from jpeglib were helpful in writing this. */ -void IMG_SaveJPG_RW( const SDL_Surface *surface, SDL_RWops *dest ) +void IMG_SaveJPG_RW( SDL_Surface *surface, SDL_RWops *dest ) { + SDL_Surface *dst_surface; + if( ConvertSDLSurface( surface, dst_surface, + surface->w, surface->h, 24, mySDL_Swap24(0xFF0000), mySDL_Swap24(0x00FF00), mySDL_Swap24(0x0000FF), 0 ) ) + surface = dst_surface; + struct jpeg::jpeg_compress_struct cinfo; /* Step 1: allocate and initialize JPEG compression object */ @@ -190,5 +196,7 @@ void IMG_SaveJPG_RW( const SDL_Surface *surface, SDL_RWops *dest ) jpeg::jpeg_destroy_compress(&cinfo); /* And we're done! */ + if( dst_surface ) + SDL_FreeSurface( dst_surface ); } diff --git a/stepmania/src/SDL_SaveJPEG.h b/stepmania/src/SDL_SaveJPEG.h index 9ab164805d..fac0b33d93 100644 --- a/stepmania/src/SDL_SaveJPEG.h +++ b/stepmania/src/SDL_SaveJPEG.h @@ -1,6 +1,6 @@ #ifndef SDL_SAVE_JPEG_H #define SDL_SAVE_JPEG_H -void IMG_SaveJPG_RW( const SDL_Surface *surface, SDL_RWops *dest ); +void IMG_SaveJPG_RW( SDL_Surface *surface, SDL_RWops *dest ); #endif