From: Leon Brocard Date: Mon, 2 Nov 2009 16:17:53 +0000 (+0000) Subject: Implement load_BMP and save_BMP X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f6b93b42290c4ae6c1ae2e1de8a096d04c85fe01;p=sdlgit%2FSDL_perl.git Implement load_BMP and save_BMP --- diff --git a/src/Core/Video.xs b/src/Core/Video.xs index 8b49408..b6af462 100644 --- a/src/Core/Video.xs +++ b/src/Core/Video.xs @@ -364,3 +364,22 @@ get_RGBA ( pixel_format, pixel ) av_push(RETVAL,newSViv(a)); OUTPUT: RETVAL + +SDL_Surface* +load_BMP ( filename ) + char *filename + PREINIT: + char* CLASS = "SDL::Surface"; + CODE: + RETVAL = SDL_LoadBMP(filename); + OUTPUT: + RETVAL + +int +save_BMP ( surface, filename ) + SDL_Surface *surface + char *filename + CODE: + RETVAL = SDL_SaveBMP(surface,filename); + OUTPUT: + RETVAL diff --git a/src/SDL.xs b/src/SDL.xs index ccfa83c..d96bb7a 100644 --- a/src/SDL.xs +++ b/src/SDL.xs @@ -1193,16 +1193,6 @@ BlitSurface ( src, src_rect, dest, dest_rect ) Comment out for now as it does not compile - -int -SaveBMP ( surface, filename ) - SDL_Surface *surface - char *filename - CODE: - RETVAL = SDL_SaveBMP(surface,filename); - OUTPUT: - RETVAL - SDL_Surface* ConvertRGB ( surface ) SDL_Surface * surface diff --git a/t/core_video.t b/t/core_video.t index a0e8b0d..eadce44 100644 --- a/t/core_video.t +++ b/t/core_video.t @@ -9,7 +9,7 @@ use Data::Dumper; use Test::More; use SDL::Rect; -plan ( tests => 30); +plan ( tests => 32); use_ok( 'SDL::Video' ); @@ -39,6 +39,8 @@ my @done = set_alpha get_RGB get_RGBA + load_BMP + save_BMP /; can_ok ('SDL::Video', @done); @@ -143,10 +145,16 @@ is_deeply(SDL::Video::get_RGB($display->format, 0), [0,0,0], '[get_RGB] returns is_deeply(SDL::Video::get_RGBA($display->format, 0), [0,0,0,255], '[get_RGBA] returns r,g,b,a'); +my $bmp = 't/core_video.bmp'; +unlink($bmp) if -f $bmp; +SDL::Video::save_BMP($display, $bmp); +ok(-f $bmp, '[save_BMP] creates a file'); +my $bmp_surface = SDL::Video::load_BMP($bmp); +isa_ok($bmp_surface, 'SDL::Surface', '[load_BMP] returns an SDL::Surface'); +unlink($bmp) if -f $bmp; + my @left = qw/ get_gamma_ramp - load_BMP - save_BMP set_clip_rect get_clip_rect blit_surface