Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing Graphics To Image

Status
Not open for further replies.

Milby7

Programmer
Dec 5, 2003
67
GB
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:

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!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top