示例#1
0
文件: GD.cs 项目: ststeiger/GdCaptcha
        public void Resize(int destW, int destH)
        {
            CheckDisposed();

            //TODO: resize img and replace this.handle with new img
            IntPtr imageHandle;

            imageHandle = GDImport.gdImageCreateTrueColor(destW, destH);
            if (imageHandle == IntPtr.Zero)
            {
                throw new ApplicationException("ImageCreatefailed.");
            }

            GDImport.gdImageCopyResampled(
                imageHandle, this.Handle,
                0, 0, 0, 0,
                destW, destH, this.Width, this.Height);

            GDImport.gdImageDestroy(this.Handle);
            this.handle = new HandleRef(this, imageHandle);
        }
示例#2
0
文件: GD.cs 项目: ststeiger/GdCaptcha
        /***********************************************************************************\
        *  GD Creation/Destruction/Loading/Saving
        \***********************************************************************************/

        public GD(int width, int height, bool trueColor)
        {
            IntPtr imageHandle;

            if (trueColor)
            {
                imageHandle = GDImport.gdImageCreateTrueColor(width, height);
            }
            else
            {
                imageHandle = GDImport.gdImageCreate(width, height);
            }

            if (imageHandle == IntPtr.Zero)
            {
                throw new ApplicationException("ImageCreate failed.");
            }

            this.handle = new HandleRef(this, imageHandle);

            //this.imageData = (GDImage) Marshal.PtrToStructure( this.Handle, typeof( GDImage ) );
        }