procedure TForm1.Button1Click(Sender: TObject);
var
lo:tbitmap;
i,j:integer;
kl:longint;
rr,gg,bb:byte;
res:byte;
begin
lo:=tbitmap.create;
lo.Width:=image1.Width;
lo.height:=image1.height;
ProgressBar1.Max:=image1.Width+1;
for i:=0 to image1.Width+1 do
begin
for j:=0 to image1.height+1 do
begin
kl:=ColorToRGB(image1.Canvas.Pixels[i,j]);
rr:=byte(kl);
gg:=byte(kl shr 8);
bb:=byte(kl shr 8);
res:=(rr+gg+bb) div 3;
lo.Canvas.Pixels[i,j]:=rgb(res,res,res);
end;
ProgressBar1.Position:=i;
end;//for do
image1.Canvas.Draw(0,0,lo);
lo.free;
end;
转载于:https://www.cnblogs.com/myamanda/articles/1542810.html