Esempio n. 1
0
        /**
         * Make a copy of the image object
         */
        /// <include file='doc\Image.uex' path='docs/doc[@for="Image.Clone"]/*' />
        /// <devdoc>
        ///    Creates an exact copy of this <see cref='System.Drawing.Image'/>.
        /// </devdoc>
        public object Clone()
        {
            IntPtr cloneImage = IntPtr.Zero;

            int status = SafeNativeMethods.GdipCloneImage(new HandleRef(this, nativeImage), out cloneImage);

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

            status = SafeNativeMethods.GdipImageForceValidation(new HandleRef(null, cloneImage));

            if (status != SafeNativeMethods.Ok)
            {
                SafeNativeMethods.GdipDisposeImage(new HandleRef(null, cloneImage));
                throw SafeNativeMethods.StatusException(status);
            }

            return(CreateImageObject(cloneImage));
        }