Is this enough:
using (Graphics g = Graphics.FromImage(image))
{
g.DrawImage(newImage.GetThumbnailImage(10, 10, null, new IntPtr()), 3, 3, 10, 10);
}
Or should I use:
using (Graphics g = Graphics.FromImage(image))
{
using (Image i = newImage.GetThumbnailImage(10, 10, null, new IntPtr()))
{
g.DrawImage(i, 3, 3, 10, 10);
}
}
EDIT:
Can someone please add some MS reference that even when there is no variable created – the resources will not be freed immediately?
It’s not going to be disposed unless you specifically call the
Dispose()method on it (or it leaves ausingblock). So in your case, using the secondusingblock would be the safer choice to make sure you free unmanaged resources.