我已经看到,绘制两个图像非常耗时,所以我想尽可能减少绘制这些图像。我使用图片编辑并覆盖了 ondraw 事件。在这里,我添加了以下部分,但它最终变成了黑色图像。我确实想检查一下,我是否需要画画。此检查有效。然后我绘制背景并将其覆盖在另一个背景上,我想将其存储为图像并将其作为我的控件的背景。
如果我不重绘背景,我只需调用:
g.Clear(Color.Transparent);
在我的图片编辑绘画事件中。
我有什么问题吗?
此致,
帕特里克
//Recalculate the background
if (redrawBackground)
{
g.FillRectangle(Brushes.White, 0, 0, backGroundImage.Width, backGroundImage.Height);
g.Clear(Color.White);
//this is drawn without aspect ration. The matrix is stored, since drawing images is expensive
GenerateTransformation(g, false);
g.DrawImageUnscaled(backGroundImage, new Rectangle(0, 0, backGroundImage.Width, backGroundImage.Height));
lastTransformation = g.Transform;
GenerateTransformation(g, true);
g.DrawImage(foreGroundImage, new Rectangle(0, 0, backGroundImage.Width, backGroundImage.Height));
lastTransformationAspect = g.Transform;
//Save bitmap as background
Bitmap bmp = new Bitmap(backGroundImage.Width, backGroundImage.Height, e.Graphics);
//Trick the background by a new image
pictureEdit.Image = bmp;
}