Hi.
This program shows a small part of what _LOADIMAGE do when reading BMP files. The program will appear without the _LOADIMAGE command. Read BMP images in 1-bit, 4-bit, 8-bit and 24-bit formats. It's just for information for those who wonder how to load the BMP file without the LOADIMAGE command. I've figured out how to fix reading CUR files, which is exactly what I'm going to do now.
'program try load 1 bit (2 color) / 4 bit (16 color) / 8 bit (256 color) / 24 bit BMP picture without _LOADIMAGE:
'i writed it, because i am interested about it... Petr
'some images are viewed correctly, some not with the same program. I am sorry, but i do not know why.
'all knowledge for writing this program so as it now is, i read from english wikipedia (Czech contains not enought informations). I found, that some
'records in english wikipedia are not correctly and then muss reapiring some head types in this program to work.....
'not writed for speed. Just for fun.
'UPGRADED: Repaired bug reading 1bit / 4 bit BMPs. X axis muss be dividible by 4! So if X pointer is already so big as is image width, but is not
'dividible by 32 (4 bytes x 8 bites), then CAN NOT BE RESTARTED BACK TO 0! Only if is X MOD 32 = 0 AND X >= image WIDTH, then can be X restarted back
'to zero. I have read about this attribute on the Czech forums about BMP format, this is not even neited writed in english wikipedia.
'I can add support for 32 bit BMPs if you send me some picture in this format.
S:
runit = runit + 1
PRINT "Opening Black/White, 1bit recorded BMP file kitten1.BMP" file$ = "kitten1.bmp"
PRINT "Opening 16 color BMP file kitten4.BMP" file$ = "kitten4.bmp"
PRINT "Opening 256 color BMP file kitten8.BMP" file$ = "kitten8.bmp"
PRINT "Opening 24bit (hi color) BMP file kitten24.BMP" file$ = "kitten24.bmp"
PRINT "Opening 1bit (2 colors) BMP file MONKEY1.BMP" file$ = "monkey1.bmp"
PRINT "Opening 16 color file MONKEY16.BMP" file$ = "monkey16.bmp"
PRINT "Opening 256 color file MONKEY256.BMP" file$ = "monkey256.bmp"
CASE 8:
PRINT "Opening 24bit file MONKEY.BMP" file$ = "monkey.bmp"
'bitmapfileheader end
crc
AS LONG 'compression if is used imgSize
AS LONG ' image data block size hr
AS LONG 'horizontal resolution in pixels / meter vr
AS LONG 'vertical resolution in pixels / meter numPalClrs
AS LONG ' number of colors in color palette impClr
AS LONG 'number of important colors used or 0
CASE 8: C
= 256: Looop
= 255 CASE 4: C
= 256: Looop
= 3 CASE 1: C
= 256: Looop
= 1
FOR LoadPalette
= 0 TO Looop
PRINT "File size returned with LOF:";
LOF(1) PRINT "File identity:"; BMP.id$
PRINT "File size writed in file:"; BMP.size
PRINT "Image data start offset:"; BMP.offset
PRINT "Header size in bytes:"; BMP.headersize
PRINT "Image height:"; BMP.height
PRINT "Planes:"; BMP.planes
PRINT "Bites per pixel:"; BMP.bpp
PRINT "Compression: "; BMP.crc
PRINT "Image size: "; BMP.imgSize
PRINT "Vertical resolution: (px/M) "; BMP.vr
PRINT "Horizontal resolution: (px/M) "; BMP.hr
PRINT "Number colors in palette: "; BMP.numPalClrs
PRINT "Number of important colors used: "; BMP.impClr
PRINT "Reserved 1: "; BMP.res1
PRINT "Reserved 2: "; BMP.res2
x = 1: y = BMP.height
IF y
= 0 THEN y
= BMP.height
- 1
x = x + 1
IF y
= 0 THEN y
= BMP.height
- 1
clr = BINtoDEC(value$)
IF y
= 0 THEN y
= BMP.height
- 1 x = 0: y = y - 1
' PSET (x, y), ASC(clr)
IF y
= 0 THEN y
= BMP.height
- 1
x = x + 1
x = 0: y = y - 1
IF vstup
AND 2 ^ rj
THEN DECtoBIN$
= DECtoBIN$
+ "1" ELSE DECtoBIN$
= DECtoBIN$
+ "0"
BINtoDEC = BINtoDEC + (c * 2 ^ Sj)