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); } }
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)); }