掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Bitmapの無地識別 (ID:21203)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
調べないといけないですね。 簡単にということなので。 簡単に調べられる関数を作りました。 (ある程度高速) function IsBlankWhite( Bitmap: TBitmap): boolean; const BitCounts: array [pf1Bit..pf32Bit] of Byte = (1,4,8,16,16,24,32); //from vcl var p: pByteArray; b,x,y,w: integer; begin with Bitmap do begin Result:= False; if Width =0 then Exit; if Height=0 then Exit; //8bit 以下は未対応 b:= BitCounts[ PixelFormat]; if b<8 then Raise Exception.Create('未対応'); //x 走査の最大値 w:= (b div 8) * (Width-1); Result:=False; //y 走査 for y:= Height-1 downto 0 do begin p:= ScanLine[y]; x:= 0; while (x<w) do begin if (p^[x]<>$FF) then Exit; inc(x); end; end; Result:= True; end; end; //with文の with Bitmap とパラメータの Bitmap を削除すれば //TBitmapを派生したクラスに簡単に組み込めます 白なら True そうでないなら False を返します。 (ただし、PixelFormatは pf8bit から pf32bit までの限定) ScanLineの叩き台になりうると思います。いろいろ実験してください。 以上。
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.