SDL surfaces don't get along with const (grr)

don't make assumptions about the format of the input surface
This commit is contained in:
Glenn Maynard
2004-02-25 05:03:13 +00:00
parent ecd2c3c515
commit 0c1ef3f594
2 changed files with 10 additions and 2 deletions
+9 -1
View File
@@ -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 );
}
+1 -1
View File
@@ -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