Esempio n. 1
0
        /// <include file='doc\Bitmap.uex' path='docs/doc[@for="Bitmap.FromResource"]/*' />
        /// <devdoc>
        /// </devdoc>
        public static Bitmap FromResource(IntPtr hinstance, String bitmapName)
        {
            IntSecurity.ObjectFromWin32Handle.Demand();

            IntPtr bitmap;

            IntPtr name = Marshal.StringToHGlobalUni(bitmapName);

            int status = SafeNativeMethods.GdipCreateBitmapFromResource(new HandleRef(null, hinstance),
                                                                        new HandleRef(null, name),
                                                                        out bitmap);

            Marshal.FreeHGlobal(name);

            if (status != SafeNativeMethods.Ok)
            {
                throw SafeNativeMethods.StatusException(status);
            }

            return(Bitmap.FromGDIplus(bitmap));
        }