Ejemplo n.º 1
0
        /// <include file='doc\Bitmap.uex' path='docs/doc[@for="Bitmap.LockBits"]/*' />
        /// <devdoc>
        ///    Locks a Bitmap into system memory.
        /// </devdoc>
        public BitmapData LockBits(Rectangle rect, ImageLockMode flags, PixelFormat format)
        {
            BitmapData bitmapdata = new BitmapData();

            GPRECT gprect = new GPRECT(rect);
            int    status = SafeNativeMethods.GdipBitmapLockBits(new HandleRef(this, nativeImage), ref gprect,
                                                                 flags, format, bitmapdata);

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

            return(bitmapdata);
        }