示例#1
0
        public Bitmap Clone(Rectangle rect, PixelFormat format)
        {
            if (rect.Width == 0 || rect.Height == 0)
            {
                throw new ArgumentException(SR.Format(SR.GdiplusInvalidRectangle, rect.ToString()));
            }

            IntPtr dstHandle = IntPtr.Zero;
            int    status    = Gdip.GdipCloneBitmapAreaI(
                rect.X,
                rect.Y,
                rect.Width,
                rect.Height,
                unchecked ((int)format),
                new HandleRef(this, nativeImage),
                out dstHandle);

            if (status != Gdip.Ok || dstHandle == IntPtr.Zero)
            {
                throw Gdip.StatusException(status);
            }

            return(new Bitmap(dstHandle));
        }