下面是我自己找到的解决方法,虽然卷起千堆雪tyn的解答与我的很相似,我还是非常感谢。
100分奉送!
var
lo:tbitmap;
i,j:integer;
kl:longint;
rr,gg,bb:byte;
res:byte;
begin
lo:=tbitmap.create;
lo.Width:=image1.Picture.Bitmap.Width;
lo.height:=image1.Picture.Bitmap.height;
ProgressBar1.Max:=image1.Picture.Bitmap.Width+1;
for i:=0 to image1.Picture.Bitmap.Width+1 do
begin
for j:=0 to image1.Picture.Bitmap.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:=round(0.3*rr+0.59*gg+0.11*bb);
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;