54 lines
1.2 KiB
Plaintext
54 lines
1.2 KiB
Plaintext
COMPILE SUBROUTINE Get_BMP_Info(File, Size, Width, Height)
|
|
|
|
$INSERT LOGICAL
|
|
|
|
DECLARE FUNCTION Blank_Struct, Msg
|
|
DECLARE SUBROUTINE Parse_Struct, Set_Status
|
|
|
|
IF Assigned(File) THEN
|
|
|
|
OSOPEN File TO BMP_File THEN
|
|
IF File[-3,3] _EQC 'BMP' THEN
|
|
|
|
InfoHeader = Blank_Struct('BITMAPINFOHEADER')
|
|
|
|
* Header = UL, SL, SL, US, US, UL, UL, UL, UL, UL, UL
|
|
|
|
OSBREAD InfoHeader FROM BMP_File AT 14 LENGTH 40
|
|
|
|
Parse_Struct(InfoHeader, 'BITMAPINFOHEADER', Size, Width, Height)
|
|
END
|
|
|
|
IF File[-3,3] _EQC 'PNG' THEN
|
|
OSBREAD Chunk FROM BMP_File AT 0 LENGTH 30
|
|
StartPos = INDEX(Chunk,'IHDR',1) + 4
|
|
|
|
HexWidth = Chunk[StartPos,4]
|
|
|
|
Width = (SEQ(HexWidth[1,1]) * 65536)
|
|
Width += (SEQ(HexWidth[2,1]) * 4096)
|
|
Width += (SEQ(HexWidth[3,1]) * 256)
|
|
Width += (SEQ(HexWidth[4,1]) * 1)
|
|
|
|
|
|
HexHeight = Chunk[StartPos+4,4]
|
|
|
|
Height = (SEQ(HexHeight[1,1]) * 65536)
|
|
Height += (SEQ(HexHeight[2,1]) * 4096)
|
|
Height += (SEQ(HexHeight[3,1]) * 256)
|
|
Height += (SEQ(HexHeight[4,1]) * 1)
|
|
|
|
Size = ''
|
|
|
|
END
|
|
|
|
OSCLOSE BMP_File
|
|
|
|
END ELSE
|
|
|
|
Set_Status(1, 'Get_BMP_Info':@SVM:'Unable to open ':QUOTE(File))
|
|
|
|
END
|
|
END
|
|
RETURN
|