[英]Moving PictureBox transparent background issue
probem: 探查:
moving object: 运动物体:
type: pictureBox
name : RobotAnimation.PicFM;
backcolor: Transparent;
background image -> 背景图片->
type: picturebox
name : pictureBox1
etc -> 等->
RobotAnimation.PicATM.Parent = pictureBox1;
step: 步:
timerTick += RobotAnimation.PicATM.Location.X +1;
problem: 问题:
moving object -> around moving object -> is flicker
How can I solve this issue? 我该如何解决这个问题?
What is "messy"? 什么是“混乱”?
However, have you set the .DoubleBuffered property of the Form? 但是,您是否设置了Form的.DoubleBuffered属性? (Is it a Form?) (是表格吗?)
If not, try that. 如果没有,请尝试。
EDIT: 编辑:
The Link provided by @LarsTech already points you towards the (inevitable) path. @LarsTech提供的链接已经将您引向(不可避免的)路径。
Before that, try to activate the .OptimizedDoubleBuffer
of you objects (Form, PictureBoxes, Panels). 在此之前,尝试激活.OptimizedDoubleBuffer
你的对象(表,PictureBoxes,面板)。
With Forms, it can be activated directly calling its .SetStyle
method: 使用Forms,可以直接调用其.SetStyle
方法来激活它:
this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint,
true);
this.UpdateStyles();
In PictureBoxes and Panels, that method is protected, you have to set it in a derived class: 在PictureBoxes和Panel中,该方法受保护,您必须在派生类中进行设置:
public class BufferedPicture : PictureBox
{
public BufferedPicture()
{
this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint, true);
this.UpdateStyles();
}
}
The use of ControlStyles.UserPaint
depends on what you are doing. ControlStyles.UserPaint
的使用取决于您在做什么。
Take a look (and follow) Control.SetStyle in Microsoft Docs. 查看(并遵循)Microsoft Docs中的Control.SetStyle 。
Also - I could be wrong here - from what I see in your animated GIF, that looks more than tearing . 另外-从我在动画GIF中看到的内容来看,我可能错了,这似乎不止于撕裂 。 It seems that your rendering is one pixel off. 看来您的渲染距离只有一个像素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.