Consider the following overriden OnPaint method for a .NET Control:
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.RotateTransform(180);
// lots of drawing code
}
Is it a problem that I do not restore the state of the e.Graphics object when I am finished?
In Java this is often done by making a copy of the passed Graphics object, thus the passed Graphics object is not altered and there is no need to restore it's state. Similar Java Question
I could achieve this in .NET by using the Save() / Restore() methods. So my questions are:
- is it neccessary/best practice in .NET to restore the graphics state ?
- how expensive are the Save() / Restore() methods?