请帮我测试这个程序,在窗口上放一个image和一个按钮, image调入
c:/windows/安装程序.bmp
unit Unit1;
interface
uses
Classes, Graphics, Controls, Forms, StdCtrls, ExtCtrls ;
type
TRGBcolor=packed record
R,G,B:integer;
end;
PRGBColor = ^TRGBcolor;
TForm1 = class(TForm)
Image1: TImage;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure Bitmap_RGB(var Bmp: TBitmap; R, G, B: Integer);
var
X, Y: Integer;
I: Byte;
ColorTable: array[0..255] of TRGBColor;
pRGB: PRGBColor;
begin
for I := 0 to 255 do
begin
ColorTable.R := Byte(I + R);
ColorTable.G := Byte(I + G);
ColorTable.B := Byte(I + B);
end;
for Y := 0 to Bmp.Height - 1 do
begin
pRGB := Bmp.ScanLine[Y];
for X := 0 to Bmp.Width - 1 do
begin
pRGB.R := ColorTable[pRGB.R].R;
pRGB.G := ColorTable[pRGB.G].G;
pRGB.B := ColorTable[pRGB.B].B;
Inc(pRGB);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var bmp:tbitmap;
begin
bmp:=tbitmap.create;
bmp.PixelFormat:=pf24bit;
bmp.width:=image1.width;
bmp.height:=image1.height;
try
bmp.Canvas.Draw(0,0,image1.picture.bitmap);
Bitmap_RGB(bmp, 10,10,100);
image1.Canvas.draw(0,0,bmp);
finally
bmp.free;
end;
end;
end.
我无论怎么做也通不过!!!