下面的代码,自己慢慢看吧:
procedure TfrmColor.Button1Click(Sender: TObject);
var
i,j,k : integer;
Source : DWORD;
begin
for i := 0 to min(328 ,Image1.Picture.Width) do
for j :=0 to min(328 ,Image1.Picture.Height) do
begin
// k := GetRValue(ColorToRGB(Image1.Canvas.Pixels[i,j]))+GetGValue(ColorToRGB(Image1.Canvas.Pixels[i,j]))+GetBValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
// k := k div 3;
Source := ColorToRGB(Image1.Canvas.Pixels[i,j]);
k := Round((0.30 * GetRValue(Source)) +
(0.59 * GetGValue(Source)) +
(0.11 * GetBValue(Source)));
Canvas.Pixels[i+320,j] := RGB(k,k,k);
end;
end;
procedure TfrmColor.Button2Click(Sender: TObject);
begin
close;
end;
procedure TfrmColor.Button3Click(Sender: TObject);
var
i,j,k, nRed, nGreen, nBlue: integer;
begin
for i := 0 to min(328 ,Image1.Picture.Width) do
for j :=0 to min(328 ,Image1.Picture.Height) do
begin
nRed := GetRValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
// nGreen := GetGValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
nBlue := GetBValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
Canvas.Pixels[i+320,j] := RGB(nRed,0,nBlue);
end;
end;
procedure TfrmColor.Button4Click(Sender: TObject);
var
i,j,k, nRed, nGreen, nBlue: integer;
begin
for i := 0 to min(328 ,Image1.Picture.Width) do
for j :=0 to min(328 ,Image1.Picture.Height) do
begin
// nRed := GetRValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
nGreen := GetGValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
nBlue := GetBValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
Canvas.Pixels[i+320,j] := RGB(0,nGreen,nBlue);
end;
end;
procedure TfrmColor.Button5Click(Sender: TObject);
var
i,j,k, nRed, nGreen, nBlue: integer;
begin
for i := 0 to min(328 ,Image1.Picture.Width) do
for j :=0 to min(328 ,Image1.Picture.Height) do
begin
nRed := GetRValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
nGreen := GetGValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
nBlue := GetBValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
Canvas.Pixels[i+320,j] := RGB(255-nRed,255-nGreen,255-nBlue);
end;
end;
procedure TfrmColor.Button6Click(Sender: TObject);
var
i,j,k, nRed, nGreen, nBlue: integer;
begin
for i := 0 to min(328 ,Image1.Picture.Width) do
for j :=0 to min(328 ,Image1.Picture.Height) do
begin
nRed := GetRValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
nGreen := GetGValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
// nBlue := GetBValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
Canvas.Pixels[i+320,j] := RGB(nRed,nGreen,0);
end;
end;
procedure TfrmColor.Button7Click(Sender: TObject);
var
i,j,k, nRed, nGreen, nBlue: integer;
begin
for i := 0 to min(328 ,Image1.Picture.Width) do
for j :=0 to min(328 ,Image1.Picture.Height) do
begin
nRed := GetRValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
nGreen := GetGValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
nBlue := GetBValue(ColorToRGB(Image1.Canvas.Pixels[i,j]));
Canvas.Pixels[i+320,j] := RGB(nRed,nBlue, nGreen);
end;
end;