protected virtual void Dispose(bool disposing)
 {
     if (GDIPlus.GdiPlusToken != 0 && nativeObject != IntPtr.Zero)
     {
         Status status = GDIPlus.GdipDisposeImage(nativeObject);
         // dispose the stream (set under Win32 only if SD owns the stream) and ...
         if (stream != null)
         {
             stream.Close();
             stream = null;
         }
         // ... set nativeObject to null before (possibly) throwing an exception
         nativeObject = IntPtr.Zero;
         GDIPlus.CheckStatus(status);
     }
 }