;-------------------------------------- ; ; 作:せつき ; HP:http://www.setsuki.com/ ; ;-------------------------------------- #define get_n(%1) if %1>99 { n=""+%1 } else { if %1>9 { n="0"+%1 } else { n="00"+%1 } } #module #deffunc f_peek val,int,int ;************************************** ; ○byte分をpeek ;************************************** mref p1,16 ;検索する変数 mref p2,1 ;検索byte数 mref p3,2 ;検索開始位置 mref s,64 ;stat sdim c,1000 : c="" : s=0 : i=0 repeat p2,p3 peek b,p1,cnt : c+=""+b+" " s+=b<<(8*i) : i++ loop return ;************************************** #global ;初期設定 ;-------------------------------------- screen 2,160,185,6 : gsel 0 sdim file,10000 sdim buf ,65535 dim clr ,256,3 objmode 1,1 : objsize 100,24 pos 0,0 : button "読み込み",*begin pos 100,0 : button "結果を保存",*hozon pos 200,0 : button "パレット表示",*colorview objmode 2,1 : pos 0,24 : mesbox buf,winx,winy-24,5,65535 ;ファイルを開く ;-------------------------------------- *begin gsel 2,-1 : gsel 0,1 dialog "bmp;*.dib",16,"" : if stat!1 : stop file=refstr ;ファイルのサイズを取得 ;-------------------------------------- exist file : flen=strsize if flen<0 : dialog "ファイルが存在しません" : stop ;BMPチェック ;-------------------------------------- sdim check,2 : bload file,check,2 if check!"BM" : dialog "BMPファイルではありません" : goto *begin ;バイナリ・ロード ;-------------------------------------- dim a,flen : bload file,a,flen getpath t,file,8 : title t+" ("+flen+"byte)" ;BMPファイルヘッダ表示 ;-------------------------------------- buf="" : buf=""+file+"\n\n" buf+="ファイルヘッダ (14 byte)\n" buf+=" 2:ファイルタイプ:"+check+"\n" f_peek a,4,2 : buf+=" 4: ファイルサイズ:"+stat+" byte\n" buf+=" 2: 予約領域:常に 0\n" buf+=" 2: 予約領域:常に 0\n" f_peek a,4,10 : buf+=" 4: 画像データまでのオフセット:"+stat+" byte\n\n" off=stat ;BMP情報ヘッダ表示 ;-------------------------------------- f_peek a,1,14 : kind=stat buf+="情報ヘッダ ("+kind+" byte)\n" buf+=" 4: 情報ヘッダサイズ:"+kind+" byte\n   (BMPの種類「" if kind=12 { buf+="OS/2 Bitmap" f_peek a,2,18 : bcWidth=stat f_peek a,2,20 : bcHeight=stat f_peek a,2,24 : bcBitCount=stat s=2 } else { buf+="Windows Bitmap" f_peek a,4,18 : bcWidth=stat f_peek a,4,22 : bcHeight=stat f_peek a,2,28 : bcBitCount=stat s=4 } int pal : pal=1<=40 { buf+=" ------------------------------\n" f_peek a,2,30 : buf+=" 4: 圧縮形式  :"+stat+" [ " if stat= 0 : buf+="BI_RGB (無圧縮)" if stat= 1 : buf+="BI_RLE8 (RunLength 8 bits/pixel)" if stat= 2 : buf+="BI_RLE4 (RunLength 4 bits/pixel)" if stat= 3 : buf+="Bitfields" if stat= 4 : buf+="BI_JPEG" if stat= 5 : buf+="BI_PNG" buf+=" ]\n" f_peek a,4,34 : buf+=" 4: 画像データ部のサイズ:"+stat+" byte\n" f_peek a,4,38 : buf+=" 4: 横方向解像度 (1mあたりの画素数):"+stat+"\n" f_peek a,4,42 : buf+=" 4: 縦方向解像度 (1mあたりの画素数):"+stat+"\n" f_peek a,4,46 : buf+=" 4: 格納されているパレット数 (使用色数):"+stat+"\n" f_peek a,4,50 : buf+=" 4: 重要なパレットのインデックス:"+stat+"\n" } if kind>=108 { buf+=" ------------------------------\n" f_peek a,4,54 : buf+=" 4: 赤のカラーマスク:"+stat+"\n" f_peek a,4,58 : buf+=" 4: 緑のカラーマスク:"+stat+"\n" f_peek a,4,62 : buf+=" 4: 青のカラーマスク:"+stat+"\n" f_peek a,4,66 : buf+=" 4: a値のカラーマスク:"+stat+"\n" f_peek a,4,70 : buf+=" 4: カラースペースタイプ:"+stat+"\n" f_peek a,4, 74 : x=stat f_peek a,4, 78 : y=stat f_peek a,4, 82 : z=stat : buf+=" 4: 赤のCIE X("+x+") Y("+y+") Z("+z+")\n" f_peek a,4, 86 : x=stat f_peek a,4, 90 : y=stat f_peek a,4, 94 : z=stat : buf+=" 4: 緑のCIE X("+x+") Y("+y+") Z("+z+")\n" f_peek a,4, 98 : x=stat f_peek a,4,102 : y=stat f_peek a,4,106 : z=stat : buf+=" 4: 青のCIE X("+x+") Y("+y+") Z("+z+")\n" f_peek a,4,110 : buf+=" 4: 赤のγ値:"+stat+"\n" f_peek a,4,114 : buf+=" 4: 緑のγ値:"+stat+"\n" f_peek a,4,118 : buf+=" 4: 青のγ値:"+stat+"\n" } if kind>=124 { buf+=" ------------------------------\n" f_peek a,4,122 : buf+=" 4: sRGB色空間タイプ:"+stat+"\n" f_peek a,4,126 : buf+=" 4: プロフィールオフセット:"+stat+"\n" f_peek a,4,130 : buf+=" 4: プロフィールサイズ:"+stat+"\n" f_peek a,4,134 : buf+=" 4: 予約:"+stat+"\n" } ;BMPカラーパレット表示 ;-------------------------------------- i=kind+14 : buf+="\nカラーパレット\n" if (bcBitCount>0)&(bcBitCount<=8) { repeat pal peek clr.cnt.2,a,i : i++ peek clr.cnt.1,a,i : i++ peek clr.cnt.0,a,i : i++ : if kind=40 : i++ get_n cnt : buf+=" No."+n+":" get_n clr.cnt.0 : buf+=""+n+" " get_n clr.cnt.1 : buf+=""+n+" " get_n clr.cnt.2 : buf+=""+n+"\n" loop } else { buf+=" パレット情報はありません。\n" } ;結果を表示 ;-------------------------------------- *view clrobj 3,3 pos 0,24 : mesbox buf,winx,winy-24,5,65535 stop ;結果をテキストファイルに保存 ;-------------------------------------- *hozon dialog "txt",17,"" if stat=1 { strlen size,buf bsave refstr,buf,size } stop ;カラーパレット表示 ;-------------------------------------- *colorview if bcBitCount>8 : dialog "パレット情報はありません。",1,"エラー" : stop gsel 2,1 : cls 0 : title "カラーパレット ("+pal+" 色)" box=10 : x=0 : y=0 repeat pal color 0,0,0 : boxf x,y,x+box-2,y+box-2 color clr.cnt.0,clr.cnt.1,clr.cnt.2 boxf x+1,y+1,x+box-3,y+box-3 x+=box : if cnt\16=15 : y+=box : x=0 loop pos 160-25/2,161 : objmode 1,0 : objsize 24,24 : button "閉",*del stop *del gsel 2,-2 : stop