Exemplo n.º 1
0
        /// <include file='doc\Bitmap.uex' path='docs/doc[@for="Bitmap.Bitmap8"]/*' />
        /// <devdoc>
        ///    Initializes a new instance of the
        /// <see cref='System.Drawing.Bitmap'/>
        /// class with the specified size and target <see cref='System.Drawing.Graphics'/>.
        /// </devdoc>
        public Bitmap(int width, int height, Graphics g)
        {
            if (g == null)
            {
                throw new ArgumentNullException("graphics");
            }

            IntPtr bitmap = IntPtr.Zero;

            int status = SafeNativeMethods.GdipCreateBitmapFromGraphics(width, height, new HandleRef(g, g.nativeGraphics), out bitmap);

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

            SetNativeImage(bitmap);
        }