From 5368b9d5d732bd16466fa2acb1a91610faea37b5 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Thu, 21 Sep 2017 23:55:01 -0300 Subject: [PATCH] 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(); --- internal/c/parts/video/image/src.c | 41 +++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/internal/c/parts/video/image/src.c b/internal/c/parts/video/image/src.c index e38b83773..672d08f3a 100644 --- a/internal/c/parts/video/image/src.c +++ b/internal/c/parts/video/image/src.c @@ -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