Ejemplo n.º 1
0
        public static Bitmap FromResource(IntPtr hinstance, string bitmapName)
        {
            IntPtr name = Marshal.StringToHGlobalUni(bitmapName);

            try
            {
                Gdip.CheckStatus(Gdip.GdipCreateBitmapFromResource(hinstance, name, out IntPtr bitmap));
                return(new Bitmap(bitmap));
            }
            finally
            {
                Marshal.FreeHGlobal(name);
            }
        }
Ejemplo n.º 2
0
        public static Bitmap FromResource(IntPtr hinstance, string bitmapName)
        {
            IntPtr bitmap;
            IntPtr name = Marshal.StringToHGlobalUni(bitmapName);

            try
            {
                int status = Gdip.GdipCreateBitmapFromResource(new HandleRef(null, hinstance),
                                                               new HandleRef(null, name),
                                                               out bitmap);
                Gdip.CheckStatus(status);
            }
            finally
            {
                Marshal.FreeHGlobal(name);
            }

            return(new Bitmap(bitmap));
        }