delphi中图像缓冲区的实现
上下文
我正在画布上绘图,它会定期更新并且闪烁。 从逻辑上讲,我认为这是因为我的重绘方法清除了画布,然后一次将一个元素绘制到画布上。所以我的想法是写入 Timage 然后将图片设置到 Timage。
信息
这是我的代码
procedure Tmainwindow.Button3Click(Sender: TObject);
var bufferpicture:TImage;
begin
//draw stuff to bufferpicture
//***
//draw stuff to bufferpicture
myrealpicture.picture:=bufferpicture.picture;
end;
运行代码后,我收到如下错误。
问题 由于画布是只读属性,如何将一个画布设置为另一个属性?或者有更好的方法来做我想做的事情吗?
Context
I am drawing to a canvas, this is updated regularly and it flashes.
Logically thinking I assumed this is because my redraw method clears the Canvas then draws one element at a time to the canvas. so my idea was to write to a Timage then set the picture to the Timage.
Information
here is my code
procedure Tmainwindow.Button3Click(Sender: TObject);
var bufferpicture:TImage;
begin
//draw stuff to bufferpicture
//***
//draw stuff to bufferpicture
myrealpicture.picture:=bufferpicture.picture;
end;
Upon running the code I get a error show below.
Question
How do I set the canvas of one to another since canvas is a read only property? or is there a better way to do what i am trying to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
myrealpicture
我会使用方法
Assign
MyRealPicture.Picture.Assign(BufferPicture.Picture);
您可以使用
BitBlt
将一个画布的内容复制到另一个画布:<前><代码>变量
后台缓冲区:TBitmap;
开始
BackBuffer := TBitmap.Create;
尝试
{这里放绘图内容}
BitBlt(Form1.Canvas.Handle, 0, 0, BackBuffer.Width, BackBuffer.Height,
BackBuffer.Canvas.Handle, 0, 0, SRCCOPY);
最后
BackBuffer.Free;
结尾;
结尾;
DoubleBuffered
属性myrealpicture
I would use the method
Assign
MyRealPicture.Picture.Assign(BufferPicture.Picture);
You can copy the content of one canvas to another using
BitBlt
:You can just use the
DoubleBuffered
property使用
DoubleBuffered
属性use the
DoubleBuffered
property