From 9f7a7a9e790d628fcc282b4270c83548ec6fa293 Mon Sep 17 00:00:00 2001 From: Luke Ceddia Date: Mon, 10 Oct 2016 20:48:15 +1100 Subject: [PATCH] Tweak image loading code to handle more image types --- internal/c/parts/video/image/decode/other/src.c | 4 +--- internal/c/parts/video/image/src.c | 15 +++++---------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/internal/c/parts/video/image/decode/other/src.c b/internal/c/parts/video/image/decode/other/src.c index ba72a88c3..01be14bd5 100644 --- a/internal/c/parts/video/image/decode/other/src.c +++ b/internal/c/parts/video/image/decode/other/src.c @@ -75,8 +75,6 @@ out=stbi_load_from_memory(content,bytes,&w,&h,&comp,4); if (out==NULL) return NULL; -if (comp!=4) return NULL; - //RGBA->BGRA uint8* cp=out; int32 x2,y2; @@ -94,4 +92,4 @@ for (x2=0;x2len) return -1;//return invalid handle if null length string //load the file -static int32 fh,result; -static int64 lof; +int32 fh,result = 0; +int64 lof; fh=gfs_open(f,1,0,0); if (fh<0) return -1; lof=gfs_lof(fh); @@ -66,22 +66,17 @@ if (lof>=2){ if ((content[0]==0xFF)&&(content[1]==0xD8)){format=1; goto got_format;}//JP[E]G }//2 -//GIF is handled by our "other" library -//'.gif' "GIF" -//if (lof>=3){ -//if ((content[0]==71)&&(content[1]==73)&&(content[2]==70)){format=4; goto got_format;}//GIF -//}//3 - got_format: static uint8 *pixels; static int32 x,y; -if (format==0) pixels=image_decode_other(content,lof,&result,&x,&y); if (format==1) pixels=image_decode_jpg(content,lof,&result,&x,&y); if (format==2) pixels=image_decode_png(content,lof,&result,&x,&y); if (format==3) pixels=image_decode_bmp(content,lof,&result,&x,&y); - +if (!(result & 1)) { + pixels=image_decode_other(content,lof,&result,&x,&y); +} free(content); if (!(result&1)) return -1;