//灰度级处理
procedure Gray(bmp: TBitmap);
var
p: PByteArray;
w: Integer;
i, j: Integer;
begin
bmp.pixelformat := pf24bit;
for i := 0 to bmp.height - 1 do
begin
p := bmp.scanline;
j := 0;
while j < (bmp.width-1) * 3 do
begin
w :=(p[j] * 28 + p[j+1] * 151 + p[j+2]*77);
w := w shr 8;
p[j] := byte(w);
p[j+1] := byte(w);
p[j+2] := byte(w);
inc(j, 3)
end;
end;
end;
procedure TForm1.g1Click(Sender: TObject);
var
Bmp : TBitMap;
begin
PaintBox1.Repaint;
Bmp := TBitMap.Create;
Bmp.Assign(Image1.Picture.Bitmap);
//Convert(Image1.Picture.Bitmap,Bmp);
Gray(bmp);
PaintBox1.Canvas.Draw(0,0,Bmp);
Bmp.Free;
end;