View Full Version : BMP bug I cant see why
Michael Clease
24-09-2007, 23:52
I have written a 256 colour .bmp file loader (might be usefull when we get TBGL_maketexture) until then i rebuild the bitmap (roughly) and save it to a file.
The original bitmap doesn't contain the colours in the palette that are used in the gfx.
I cant find any solid information anywhere about palettes and system palettes.
heres what I've got at the moment. I know i can replace "sMsg = sMsg +" with "sMsg +=" but this way I can paste it into PB and compile to a dll without modifying it. ;D
anyhelp anyone?
thanks
mike
Petr Schreiber
25-09-2007, 15:15
- deleted my own posts :D -
Now I get it abraxas, I will post solution this night, but I have to go out now
Petr
Petr Schreiber
25-09-2007, 19:20
Here it is :)
Petr
Petr Schreiber
25-09-2007, 19:41
Hi,
here is last version using memory overlays almost exclusively.
This saves us time on conversion string elements to numeric types ( about 4x faster ).
Regarding "where was problem" I would like to answer, but I am not sure.
So I did little remake which uses another approach.
In original I was a bit confused about some parts of code ( + 14 offset for Temp ), so I did the some parts new from the scratch :-[
Thanks,
Petr
Michael Clease
26-09-2007, 01:34
thanks Petr. I was just trying to get it to work before a rewrite in PB.
14 was the file header size. I was a byte out.
LOCAL R as BYTE
LOCAL G as BYTE
LOCAL B as BYTE
local Temp as DWORD
saveBuffer = mid$(FileBuffer,1,54) ' Copy header to Save Buffer
MID$(SaveBuffer,29) = MKI$(24) ' Set to 24 bit
MID$(SaveBuffer,11) = MKI$(Len(SaveBuffer)) ' Set new offset value
for n = 1 to BisizeImage ' to 1 step -1 ' Loop until we have read all bytes of bitmap
Temp = CVBYT (FileBuffer, bfOffBits+n) ' Read byte from bitmap convert from string to byte
Temp = (Temp * 4 ) ' Set palette offset (RGB0) 4 bytes
B = CVBYT (FileBuffer, 14+1+Temp+biSize) ' Blue Palette Using Bitmap Offset. Fileheader+1+offset+infoheader
G = CVBYT (FileBuffer, 14+2+Temp+biSize) ' Green Palette Using Bitmap Offset.
R = CVBYT (FileBuffer, 14+3+Temp+biSize) ' Red Palette Using Bitmap Offset.
SaveBuffer += MKBYT$ (B) ' Build new bitmap
SaveBuffer += MKBYT$ (G) ' ...
SaveBuffer += MKBYT$ (R) ' ..
' SAVEBuffer += MKBYT$ (0) ' Dont forget the pad byte.
NEXT