I would like to use GDI + to render an image in a background thread. I found this example on how to rotate an image using GDI +, which I would like to do.
private void RotationMenu_Click(object sender, System.EventArgs e)
{
Graphics g = this.CreateGraphics();
g.Clear(this.BackColor);
Bitmap curBitmap = new Bitmap(@"roses.jpg");
g.DrawImage(curBitmap, 0, 0, 200, 200);
Matrix X = new Matrix();
X.Rotate(30);
g.Transform = X;
g.DrawImage(curBitmap,
new Rectangle(205, 0, 200, 200),
0, 0, curBitmap.Width,
curBitmap.Height,
GraphicsUnit.Pixel);
curBitmap.Dispose();
g.Dispose();
}
My question has two parts:
How would you do this.CreateGraphics()in the background thread? Is it possible? I understand that the UI object thisin this example. So, if I do this processing in the background thread, how would I create a graphic?
How can I extract a bitmap from a Graphics object that I use when I'm done processing? I could not find a good example of how to do this.
: , ? - , , . !