Hello, I am using a transparent PNG graphic on a user control.
Several controls (100x100px) makes a slow display of complete form and disturbs users.
Is there a mechanism to make it faster? for example when at the first drawing of control, save the final image as Bitmap, then do not try to paint all graphics having transparency everytime when painting required. Somehow caching mechanism.
Thank in advance for your ideas.
The code is simple, you are just overriding the OnPaint, and drawing some image and text. The image has transparency and this makes slower UI when the program run on a relatively slower machine. But I certainly need transparency.
protected override void OnPaint(PaintEventArgs e)
{
g.DrawImage(this.Image, r, 0, 0, this.Image.Width, this.Image.Height, GraphicsUnit.Pixel);
g.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), r, sf);
}