home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-386-Vol-2of3.iso
/
b
/
baswiz19.zip
/
BW$BAS.ZIP
/
GETINFOB.BAS
< prev
next >
Wrap
BASIC Source File
|
1993-01-30
|
2KB
|
50 lines
' +----------------------------------------------------------------------+
' | |
' | BASWIZ Copyright (c) 1990-1993 Thomas G. Hanlin III |
' | |
' | The BASIC Wizard's Library |
' | |
' +----------------------------------------------------------------------+
DECLARE SUB FOpen (File$, FMode$, BufferLen%, Handle%, ErrCode%)
DECLARE FUNCTION FGetSize& (BYVAL Handle%)
DECLARE FUNCTION FRead$ (BYVAL Handle%, BYVAL Bytes%)
DECLARE SUB FClose (Handle%)
SUB GetInfoBMP (File$, PicWidth%, PicHeight%, PicColors%, ErrCode%)
ErrCode% = 0
FOpen File$, "R", 100, Handle%, ErrCode%
IF ErrCode% = 0 THEN
Header$ = FRead$(Handle%, 34)
IF FGetError% OR (LEN(Header$) <> 34) THEN
ErrCode% = FGetError%
ELSE
PWide& = CVL(MID$(Header$, 19, 4))
PHigh& = CVL(MID$(Header$, 23, 4))
BitPlanes% = CVI(MID$(Header$, 27, 2))
ColorBits% = CVI(MID$(Header$, 29, 2))
IF LEFT$(Header$, 2) <> "BM" THEN
ErrCode% = -1 ' invalid BMP
ELSEIF NOT (BitPlanes% = 1 AND (ColorBits% = 4 OR ColorBits% = 8)) THEN
ErrCode% = -2 ' color format not supported
ELSEIF CVL(MID$(Header$, 31, 4)) <> 0& THEN
ErrCode% = -3 ' compression not supported
ELSEIF CVL(MID$(Header$, 3, 4)) <> FGetSize&(Handle%) THEN
ErrCode% = -4 ' incorrect file size
ELSEIF PWide& < 1& OR PWide& > 32767& OR PHigh& < 1& OR PHigh& > 32767& THEN
ErrCode% = -5 ' ludicrous image size
END IF
IF ErrCode% = 0 THEN
PicWidth% = PWide&
PicHeight% = PHigh&
IF ColorBits% = 4 THEN
PicColors% = 16
ELSE
PicColors% = 256
END IF
END IF
END IF
FClose Handle%
END IF
END SUB