D
donkey
Unregistered / Unconfirmed
GUEST, unregistred user!
我想创建一个Bitmap,然后在bitmap.canvas上作图,最后显示在特定控件的表面上解决
闪烁问题,但是CopyRect无法工作,大家帮我看看
var
BufBitmap:TBitmap;//内存中的bitmap
Time1,Time2,Time3:TDateTime ;
str:string;
DesR,ScrR:TRect;
begin
if OpenPictureDialog1.Execute then
begin
try
Time1:=Time;
BufBitmap := TBitmap.Create ;
BufBitmap.Width := Image1.Width ;
BufBitmap.Height := image1.Height ;
BufBitmap.PixelFormat := pf16bit;
BufBitmap.LoadFromFile (OpenPictureDialog1.FileName );
if CheckBox1.Checked then
begin
BufBitmap.TransparentColor := BufBitmap.Canvas.Pixels[1,1];
BufBitmap.Transparent := true;
end
else
BufBitmap.Transparent :=false;
BufBitmap.Canvas.TextOut (0,0,'hello@@%#^**');
image3.Picture.Bitmap.Assign(BufBitmap ); //这一句正常,说明BufBitmap上有图像了
Time2:=Time;
DesR.Top :=0;
DesR.Left :=0;
DesR.Right := Image1.Width ;
DesR.Bottom := Image1.Height;
//下面这一句没有显示任何图像
Image2.Picture.Bitmap.Canvas.StretchDraw (DesR,BufBitmap);
with image1.Picture.Bitmap do
begin
//这一句也没有任何效果
Canvas.CopyMode := cmSrcCopy ;
Canvas.CopyRect ( DesR ,BufBitmap.Canvas , DesR);
end;
Time3:=Time;
Label1.Caption :=FormatDateTime('"开始时间:"ss"秒"zzz"毫秒;"',Time1);
Label1.Caption :=Label1.Caption + FormatDateTime('"装载完毕:"ss"秒"zzz"毫秒;"',Time2);
Label1.Caption :=Label1.Caption + FormatDateTime('"显示完毕:"ss"秒"zzz"毫秒"',Time3);
Label2.Caption :=FormatDateTime('"开始时间-装载完毕:"ss"秒"zzz"毫秒;"',Time2-Time1);
Label2.Caption :=Label2.Caption + FormatDateTime('"装载完毕-显示完毕:"ss"秒"zzz"毫秒;"',Time3-Time2);
Label2.Caption :=Label2.Caption + FormatDateTime('"开始时间-显示完毕:"ss"秒"zzz"毫秒;"',Time3-Time1);
finally
BufBitmap.Free ;
end;
end;
end;
闪烁问题,但是CopyRect无法工作,大家帮我看看
var
BufBitmap:TBitmap;//内存中的bitmap
Time1,Time2,Time3:TDateTime ;
str:string;
DesR,ScrR:TRect;
begin
if OpenPictureDialog1.Execute then
begin
try
Time1:=Time;
BufBitmap := TBitmap.Create ;
BufBitmap.Width := Image1.Width ;
BufBitmap.Height := image1.Height ;
BufBitmap.PixelFormat := pf16bit;
BufBitmap.LoadFromFile (OpenPictureDialog1.FileName );
if CheckBox1.Checked then
begin
BufBitmap.TransparentColor := BufBitmap.Canvas.Pixels[1,1];
BufBitmap.Transparent := true;
end
else
BufBitmap.Transparent :=false;
BufBitmap.Canvas.TextOut (0,0,'hello@@%#^**');
image3.Picture.Bitmap.Assign(BufBitmap ); //这一句正常,说明BufBitmap上有图像了
Time2:=Time;
DesR.Top :=0;
DesR.Left :=0;
DesR.Right := Image1.Width ;
DesR.Bottom := Image1.Height;
//下面这一句没有显示任何图像
Image2.Picture.Bitmap.Canvas.StretchDraw (DesR,BufBitmap);
with image1.Picture.Bitmap do
begin
//这一句也没有任何效果
Canvas.CopyMode := cmSrcCopy ;
Canvas.CopyRect ( DesR ,BufBitmap.Canvas , DesR);
end;
Time3:=Time;
Label1.Caption :=FormatDateTime('"开始时间:"ss"秒"zzz"毫秒;"',Time1);
Label1.Caption :=Label1.Caption + FormatDateTime('"装载完毕:"ss"秒"zzz"毫秒;"',Time2);
Label1.Caption :=Label1.Caption + FormatDateTime('"显示完毕:"ss"秒"zzz"毫秒"',Time3);
Label2.Caption :=FormatDateTime('"开始时间-装载完毕:"ss"秒"zzz"毫秒;"',Time2-Time1);
Label2.Caption :=Label2.Caption + FormatDateTime('"装载完毕-显示完毕:"ss"秒"zzz"毫秒;"',Time3-Time2);
Label2.Caption :=Label2.Caption + FormatDateTime('"开始时间-显示完毕:"ss"秒"zzz"毫秒;"',Time3-Time1);
finally
BufBitmap.Free ;
end;
end;
end;