掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
カラーのBMPファイルを、モノクロBMPに変換するには? (ID:1018)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
D2では ScanLineが使えません。代わりに Pixelsを使うことになります。 ScanLineなら一瞬で変換されますが、Pixelsでは、変換速度が かなり遅くなってしまいます。 大きな画像では実用的ではないですね。 function EffectGrayScaleColor(hBMP: HBitmap): HBitmap; var Row, Col : Integer; SrcRGB, RGB : TColor; R, G, B : Integer; SrcBitmap, DestBitmap : TBitmap; begin SrcBitmap := TBitmap.Create; DestBitmap := TBitmap.Create; SrcBitmap.Handle := hBMP; //Set24bit(SrcBitmap,DestBitmap); DestBitmap.Width := SrcBitmap.Width; DestBitmap.Height := SrcBitmap.Height; try for Row:=0 to SrcBitmap.Height-1 do begin for Col:=0 to SrcBitmap.Width-1 do begin //NTSC系加重平均法を用いてグレースケール化 SrcRGB := SrcBitmap.Canvas.Pixels[Col,Row]; R := Round((SrcRGB and $ff0000 shr 16) * 0.289); G := Round((SrcRGB and $00ff00 shr 8 ) * 0.586); B := Round((SrcRGB and $0000ff ) * 0.114); RGB := R + G + B; DestBitmap.Canvas.Pixels[Col,Row] := (RGB shl 16) + (RGB shl 8) + RGB; end; end; Result := DestBitmap.ReleaseHandle; except Result := SrcBitmap.ReleaseHandle; end; SrcBitmap.Free ; DestBitmap.Free; end;
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.