瀏覽代碼

Added surface LoadBMP().

woollybah 7 年之前
父節點
當前提交
d8daab08ad
共有 3 個文件被更改,包括 17 次插入0 次删除
  1. 2 0
      sdlsurface.mod/common.bmx
  2. 8 0
      sdlsurface.mod/glue.c
  3. 7 0
      sdlsurface.mod/sdlsurface.bmx

+ 2 - 0
sdlsurface.mod/common.bmx

@@ -88,6 +88,8 @@ Extern
 	Function bmx_sdl_surface_Blit:Int(handle:Byte Ptr, sx:Int, sy:Int, sw:Int, sh:Int, dest:Byte Ptr, dx:Int, dy:Int)
 	Function bmx_sdl_surface_BlitScaled:Int(handle:Byte Ptr, sx:Int, sy:Int, sw:Int, sh:Int, dest:Byte Ptr, dx:Int, dy:Int)
 	
+	Function bmx_sdl_LoadBMP:Byte Ptr(file:String)
+	
 End Extern
 
 Rem

+ 8 - 0
sdlsurface.mod/glue.c

@@ -21,6 +21,7 @@
     distribution.
 */
 #include "SDL_surface.h"
+#include "brl.mod/blitz.mod/blitz.h"
 
 SDL_PixelFormat * bmx_sdl_surface_Format(SDL_Surface * surface) {
 	return surface->format;
@@ -101,5 +102,12 @@ int bmx_sdl_surface_BlitScaled(SDL_Surface * surface, int sx, int sy, int sw, in
 	return SDL_BlitScaled(surface, (sw==0 && sh==0 && sx==0 && sy==0) ? NULL : &sr, dest, &dr);
 }
 
+SDL_Surface * bmx_sdl_LoadBMP(BBString * file) {
+	char * f = bbStringToUTF8String(file);
+	SDL_Surface * surface = SDL_LoadBMP(f);
+	bbMemFree(f);
+	return surface;
+}
+
 
 

+ 7 - 0
sdlsurface.mod/sdlsurface.bmx

@@ -85,6 +85,13 @@ Type TSDLSurface
 		Return _create(SDL_CreateRGBSurfaceFrom(pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask))
 	End Function
 	
+	Rem
+	bbdoc: Loads a surface from a BMP file.
+	End Rem
+	Function LoadBMP:TSDLSurface(file:String)
+		Return _create(bmx_sdl_LoadBMP(file))
+	End Function
+	
 	Rem
 	bbdoc: Copies the surface to a new surface of the specified format.
 	returns: The new surface, or Null on failure.