!BMPファイル(圧縮なし)のデータを数値表示する 参考 http://www.kk.iij4u.or.jp/~kondo/bmp/
OPTION CHARACTER byte
LET BFile$=StructDim$("BITMAPFILEHEADER") !Dim BFile As BITMAPFILEHEADER LET BInfo$=StructDim$("BITMAPINFOHEADER") !Dim BInfo As BITMAPINFOHEADER LET BPalt$=StructDim$("RGBQUAD") !Dim BPalt As RGBQUAD
file getname f$,"BMPファイル|*.BMP" !ファイル名を得る IF f$="" THEN STOP
OPEN #1: NAME f$, ACCESS INPUT LET cp=0 !読み込み現在位置
!---------- ファイルヘッダ部 LET p=0 !読み込み位置 CALL fseek(p) !Get #1,0,BFile ※VisualBasic CALL fread(BFile$,p)
PRINT GetValOf$(BFile$,"BITMAPFILEHEADER","bfType") !BFile.bfType LET bfSize=GetValOf(BFile$,"BITMAPFILEHEADER","bfSize") !BFile.bfSize PRINT bfSize PRINT GetValOf(BFile$,"BITMAPFILEHEADER","bfReserved1") PRINT GetValOf(BFile$,"BITMAPFILEHEADER","bfReserved2") LET bfOffBits=GetValOf(BFile$,"BITMAPFILEHEADER","bfOffBits") PRINT bfOffBits PRINT
!---------- 情報ヘッダ部(Windows Bitmap) CALL fread(BInfo$,p) !Get #1, ,BInfo
PRINT GetValOf(BInfo$,"BITMAPINFOHEADER","biSize") LET biWidth=GetValOf(BInfo$,"BITMAPINFOHEADER","biWidth") PRINT biWidth LET biHeight=GetValOf(BInfo$,"BITMAPINFOHEADER","biHeight") PRINT biHeight PRINT GetValOf(BInfo$,"BITMAPINFOHEADER","biPlanes") LET biBitCount=GetValOf(BInfo$,"BITMAPINFOHEADER","biBitCount") PRINT biBitCount LET biCompression=GetValOf(BInfo$,"BITMAPINFOHEADER","biCompression") PRINT biCompression PRINT GetValOf(BInfo$,"BITMAPINFOHEADER","biSizeImage") PRINT GetValOf(BInfo$,"BITMAPINFOHEADER","biXPelsPerMeter") PRINT GetValOf(BInfo$,"BITMAPINFOHEADER","biYPelsPerMeter") PRINT GetValOf(BInfo$,"BITMAPINFOHEADER","biClrUsed") PRINT GetValOf(BInfo$,"BITMAPINFOHEADER","biClrImportant") PRINT
!---------- 情報ヘッダ部(パレット部) IF biBitCount<=8 THEN FOR k=0 TO 2^biBitCount-1 CALL fread(BPalt$,p) !Get #1, ,BPalt PRINT USING "### 番 ": k; PRINT GetValOf2(BPalt$,"RGBQUAD","rgbBlue"), !BPalt ※符号なし PRINT GetValOf2(BPalt$,"RGBQUAD","rgbGreen"), PRINT GetValOf2(BPalt$,"RGBQUAD","rgbRed"), PRINT GetValOf2(BPalt$,"RGBQUAD","rgbReserved") NEXT k END IF PRINT
IF biCompression<>0 THEN PRINT "圧縮形式は未サポートです。" STOP END IF
|