Пример #1
0
 private IntPtr _GetHICONFromImageSource(ImageSource image, Size dimensions)
 {
     if (this._gdipToken == null)
     {
         this._gdipToken = SafeGdiplusStartupToken.Startup();
     }
     return(Utility.GenerateHICON(image, dimensions));
 }
Пример #2
0
        // Caller is responsible for destroying the HICON.
        private IntPtr _GetHICONFromImageSource(ImageSource image, Size dimensions)
        {
            // Verify that GDI+ has been initialized.  Putting this behind a SafeHandle to ensure it gets shutdown.
            if (null == _gdipToken)
            {
                _gdipToken = SafeGdiplusStartupToken.Startup();
            }

            return(Utility.GenerateHICON(image, dimensions));
        }
    public static SafeGdiplusStartupToken Startup()
    {
        SafeGdiplusStartupToken safeGdiplusStartupToken = new SafeGdiplusStartupToken();
        IntPtr        handle;
        StartupOutput startupOutput;

        if (NativeMethods.GdiplusStartup(out handle, new StartupInput(), out startupOutput) == Status.Ok)
        {
            safeGdiplusStartupToken.handle = handle;
            return(safeGdiplusStartupToken);
        }
        safeGdiplusStartupToken.Dispose();
        throw new Exception("Unable to initialize GDI+");
    }