mirror of
https://github.com/QB64Official/qb64.git
synced 2024-07-18 07:05:15 +00:00
Tweak image loading code to handle more image types
This commit is contained in:
parent
0f82a86131
commit
9f7a7a9e79
|
@ -75,8 +75,6 @@ out=stbi_load_from_memory(content,bytes,&w,&h,&comp,4);
|
||||||
|
|
||||||
if (out==NULL) return NULL;
|
if (out==NULL) return NULL;
|
||||||
|
|
||||||
if (comp!=4) return NULL;
|
|
||||||
|
|
||||||
//RGBA->BGRA
|
//RGBA->BGRA
|
||||||
uint8* cp=out;
|
uint8* cp=out;
|
||||||
int32 x2,y2;
|
int32 x2,y2;
|
||||||
|
|
|
@ -30,8 +30,8 @@ bpp=-1;
|
||||||
}
|
}
|
||||||
if (!f->len) return -1;//return invalid handle if null length string
|
if (!f->len) return -1;//return invalid handle if null length string
|
||||||
//load the file
|
//load the file
|
||||||
static int32 fh,result;
|
int32 fh,result = 0;
|
||||||
static int64 lof;
|
int64 lof;
|
||||||
fh=gfs_open(f,1,0,0);
|
fh=gfs_open(f,1,0,0);
|
||||||
if (fh<0) return -1;
|
if (fh<0) return -1;
|
||||||
lof=gfs_lof(fh);
|
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
|
if ((content[0]==0xFF)&&(content[1]==0xD8)){format=1; goto got_format;}//JP[E]G
|
||||||
}//2
|
}//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:
|
got_format:
|
||||||
|
|
||||||
static uint8 *pixels;
|
static uint8 *pixels;
|
||||||
static int32 x,y;
|
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==1) pixels=image_decode_jpg(content,lof,&result,&x,&y);
|
||||||
if (format==2) pixels=image_decode_png(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 (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);
|
free(content);
|
||||||
if (!(result&1)) return -1;
|
if (!(result&1)) return -1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue