Hi!
Can anyone tell me how to write the contents of a Graphics object to an Image. I want to write custom painting logic to the clipboard for debugging.
So far i've got:
Cheers!
Can anyone tell me how to write the contents of a Graphics object to an Image. I want to write custom painting logic to the clipboard for debugging.
So far i've got:
Code:
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawImage(_image,
new Rectangle(this.ClientRectangle.X,
this.ClientRectangle.Y,
this.ClientRectangle.Width,
this.ClientRectangle.Height));
DrawBorder(e.Graphics);
if (this.Focused)
ControlPaint.DrawFocusRectangle(e.Graphics, Rectangle.Inflate(this.ClientRectangle, -2, -2));
Bitmap bmp = null; // i want to set this to the contents of e.Graphics
Clipboard.SetImage(bmp);
}
Cheers!