Prechádzať zdrojové kódy

gif loading using callbacks.

Brucey 3 rokov pred
rodič
commit
fdf6759686
3 zmenil súbory, kde vykonal 20 pridanie a 2 odobranie
  1. 2 2
      stb.mod/common.bmx
  2. 14 0
      stb.mod/glue.c
  3. 4 0
      stb.mod/stb.bmx

+ 2 - 2
stb.mod/common.bmx

@@ -22,10 +22,10 @@ Import "stb/*.h"
 Import "glue.c"
 
 Extern
-
 	Function stbi_image_free(handle:Byte Ptr)
 	Function bmx_stbi_load_image:Byte Ptr(cb:Object, width:Int Ptr, height:Int Ptr, channels:Int Ptr)
-
+	Function bmx_stbi_load_gif:Byte Ptr(cb:Object, delays:Int Ptr Ptr, x:Int Var, y:Int Var, z:Int Var, comp:Int Var, requiredComp:Int)
+	Function bmx_stbi_free_delays(delays:Int Ptr Ptr)
 End Extern
 
 

+ 14 - 0
stb.mod/glue.c

@@ -42,3 +42,17 @@ stbi_uc * bmx_stbi_load_image(BBObject * cb, int * width, int * height, int * ch
 
 	return stbi_load_from_callbacks(&callbacks, cb, width, height, channels, 0);
 }
+
+stbi_uc * bmx_stbi_load_gif(BBObject * cb, int **delays, int *x, int *y, int *z, int *comp, int req_comp) {
+
+	stbi_io_callbacks callbacks;
+	callbacks.read = image_stb_TStbioCallbacks__Read;
+	callbacks.skip = image_stb_TStbioCallbacks__Skip;
+	callbacks.eof = image_stb_TStbioCallbacks__Eof;
+
+	return stbi_load_gif_from_callbacks(&callbacks, cb, delays, x, y, z, comp, req_comp);
+}
+
+void bmx_stbi_free_delays(int ** delays) {
+   if (delays && *delays) STBI_FREE(*delays);
+}

+ 4 - 0
stb.mod/stb.bmx

@@ -39,6 +39,8 @@ Import BRL.Pixmap
 Import "common.bmx"
 
 
+Private
+
 Type TPixmapLoaderSTB Extends TPixmapLoader
 
 	Method LoadPixmap:TPixmap( stream:TStream ) Override
@@ -99,6 +101,7 @@ Type TPixmapLoaderSTB Extends TPixmapLoader
 
 End Type
 
+Public
 
 Type TStbioCallbacks
 
@@ -130,4 +133,5 @@ Type TStbioCallbacks
 	
 End Type
 
+Private
 New TPixmapLoaderSTB