mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-05 22:50:23 +00:00
Initial attempt to restore _LOADIMAGE's ability to load in 8bit mode.
- When mode = 256, _LOADIMAGE will return an 8bit image with the loaded file's colors matching the default palette. - Slower for bigger images, because of the call to matchcol();
This commit is contained in:
parent
11bca56e8d
commit
5368b9d5d7
|
@ -1,3 +1,5 @@
|
|||
extern uint32 matchcol(int32 r,int32 g,int32 b);
|
||||
|
||||
#ifndef DEPENDENCY_IMAGE_CODEC
|
||||
//Stub(s):
|
||||
int32 func__loadimage(qbs *f,int32 bpp,int32 passed);
|
||||
|
@ -15,6 +17,16 @@
|
|||
#include "decode/other/src.c" //PNG, TGA, BMP, PSD, GIF, HDR, PIC, PNM(PPM/PGM)
|
||||
#endif
|
||||
|
||||
inline int32 func__red32(uint32 col){
|
||||
return col>>16&0xFF;
|
||||
}
|
||||
inline int32 func__green32(uint32 col){
|
||||
return col>>8&0xFF;
|
||||
}
|
||||
inline int32 func__blue32(uint32 col){
|
||||
return col&0xFF;
|
||||
}
|
||||
|
||||
int32 func__loadimage(qbs *f,int32 bpp,int32 passed){
|
||||
if (new_error) return 0;
|
||||
|
||||
|
@ -83,9 +95,32 @@ if (!(result&1)) return -1;
|
|||
//...
|
||||
|
||||
static int32 i;
|
||||
i=func__newimage(x,y,32,1);
|
||||
if (i==-1){free(pixels); return -1;}
|
||||
memcpy(img[-i].offset,pixels,x*y*4);
|
||||
static int32 prevDest;
|
||||
static uint16 scanX, scanY;
|
||||
static uint8 red, green, blue;
|
||||
|
||||
if (bpp==256) {
|
||||
i=func__newimage(x,y,256,1);
|
||||
if (i==-1){free(pixels); return -1;}
|
||||
prevDest=func__dest();
|
||||
sub__dest(i);
|
||||
|
||||
for (scanY=0;scanY<y;scanY++){
|
||||
for (scanX=0;scanX<x;scanX++){
|
||||
blue=*pixels; pixels++;
|
||||
green=*pixels; pixels++;
|
||||
red=*pixels; pixels++;
|
||||
pixels++; //skip alpha
|
||||
pset(scanX,scanY,matchcol(red,green,blue));
|
||||
}
|
||||
}
|
||||
|
||||
sub__dest(prevDest);
|
||||
} else {
|
||||
i=func__newimage(x,y,32,1);
|
||||
if (i==-1){free(pixels); return -1;}
|
||||
memcpy(img[-i].offset,pixels,x*y*4);
|
||||
}
|
||||
free(pixels);
|
||||
|
||||
if (isHardware){
|
||||
|
|
Loading…
Reference in a new issue