Exemplo n.º 1
0
        internal Bitmap GetInternalBitmap()
        {
            if (bitmap == null)
            {
                if (GDIPlus.RunningOnUnix())
                {
                    // Mono's libgdiplus doesn't require to keep the stream alive when loading images
                    using (MemoryStream ms = new MemoryStream()) {
                        // save the current icon
                        Save(ms, Width, Height);
                        ms.Position = 0;

                        // libgdiplus can now decode icons
                        bitmap = (Bitmap)Image.LoadFromStream(ms, false);
                    }
                }
                else
                {
                    // MS GDI+ ICO codec is more limited than the MS Icon class
                    // so we can't, reliably, get bitmap using it. We need to do this the "slow" way
                    bitmap = BuildBitmapOnWin32();
                }
            }
            return(bitmap);
        }
Exemplo n.º 2
0
        internal Bitmap GetInternalBitmap()
        {
            if (bitmap == null)
            {
                // Mono's libgdiplus doesn't require to keep the stream alive when loading images
                using (MemoryStream ms = new MemoryStream())
                {
                    // save the current icon
                    Save(ms, Width, Height);
                    ms.Position = 0;

                    // libgdiplus can now decode icons
                    bitmap = (Bitmap)Image.LoadFromStream(ms, false);
                }
            }
            return(bitmap);
        }