A
amartapple
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);
var
tempBitmap:TBitmap;
i,j:integer;
RP,GP:real;
begin
tempBitmap:=TBitmap.Create;
FileName:='test.bmp';
try
begin
tempBitmap.LoadFromFile(FileName);
image1.Picture.LoadFromFile(FileName);
ProgressBar1.Max:=tempBitmap.Height*tempBitmap.Width;
ProgressBar1.Visible:=true;
for i:=0 to tempBitmap.Height-1 do
begin
pRGB := tempBitmap.ScanLine;
for j:=0 to tempBitmap.Width-1 do
begin
RP:=Get_r(pRGB^.rgbtRed,pRGB^.rgbtGreen,pRGB^.rgbtBlue);
GP:=Get_g(pRGB^.rgbtRed,pRGB^.rgbtGreen,pRGB^.rgbtBlue);
{
如果去掉这一句,速度会提高几十倍,可是这句实现的功能是本程
序核心,请大家帮忙优化一下这句的功能就是按比例换算RP,GP,
并使rg(TImage)上对应的点(RP,GP)变红,详见底下函数DrawPix
}
DrawPix(rg,RP,GP);
ProgressBar1.Position:=i*tempBitmap.Width+j;
application.ProcessMessages;
Inc(pRGB);
end
end;
ProgressBar1.Visible:=false;
end;
finally
tempBitmap.Free;
end;
end;
procedure TForm1.DrawPix(Des:TImage;X:real;Y:real);
begin
X:=50*X/0.2;
Y:=50*Y/0.2;
Des.Canvas.Pixels[trunc(X),trunc(Y)]:=clRed;
end;
end.
var
tempBitmap:TBitmap;
i,j:integer;
RP,GP:real;
begin
tempBitmap:=TBitmap.Create;
FileName:='test.bmp';
try
begin
tempBitmap.LoadFromFile(FileName);
image1.Picture.LoadFromFile(FileName);
ProgressBar1.Max:=tempBitmap.Height*tempBitmap.Width;
ProgressBar1.Visible:=true;
for i:=0 to tempBitmap.Height-1 do
begin
pRGB := tempBitmap.ScanLine;
for j:=0 to tempBitmap.Width-1 do
begin
RP:=Get_r(pRGB^.rgbtRed,pRGB^.rgbtGreen,pRGB^.rgbtBlue);
GP:=Get_g(pRGB^.rgbtRed,pRGB^.rgbtGreen,pRGB^.rgbtBlue);
{
如果去掉这一句,速度会提高几十倍,可是这句实现的功能是本程
序核心,请大家帮忙优化一下这句的功能就是按比例换算RP,GP,
并使rg(TImage)上对应的点(RP,GP)变红,详见底下函数DrawPix
}
DrawPix(rg,RP,GP);
ProgressBar1.Position:=i*tempBitmap.Width+j;
application.ProcessMessages;
Inc(pRGB);
end
end;
ProgressBar1.Visible:=false;
end;
finally
tempBitmap.Free;
end;
end;
procedure TForm1.DrawPix(Des:TImage;X:real;Y:real);
begin
X:=50*X/0.2;
Y:=50*Y/0.2;
Des.Canvas.Pixels[trunc(X),trunc(Y)]:=clRed;
end;
end.