//灰階處理
imgBMP := TBitmap.create;
imgBMP.LoadFromFile(ret_filename);
pr_Set_Gray(imgBMP);
imgJPG := TJPEGImage.Create;
imgJPG.Grayscale :=True;
imgJPG.Assign(imgBmp);
imgJPG.SaveToFile(ret_filename);
procedure pr_Set_Gray(var Picture: TBitmap);
var iX, iY:Integer;
rgb1: TColor;
f, r, g, b: byte;
begin
for iX:=0 to Picture.Width-1 do
begin
for iY:=0 to Picture.Height-1 do
begin
rgb1:= Picture.Canvas.Pixels[iX, iY];
r := GetRValue(rgb1);
g := GetGValue(rgb1);
b := GetBValue(rgb1);
if b < 200 then
f := 0
else
f := 255;
Picture.Canvas.Pixels[iX, iY] := RGB(f, f, f);
end;
end;
end;
沒有留言:
張貼留言