Example #1
0
 public void EnumerateMetafile(Metafile metafile, Point destPoint, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
 {
     throw null;
 }
Example #2
0
 public void EnumerateMetafile(Metafile metafile, RectangleF destRect, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
 {
     throw null;
 }
Example #3
0
 public void DrawImage(Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
 {
     throw null;
 }
Example #4
0
 public void DrawImage(Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
 {
     throw null;
 }
Example #5
0
 public void DrawImage(Image image, Point[] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
 {
     throw null;
 }
Example #6
0
 public void DrawImage(Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback)
 {
     throw null;
 }
Example #7
0
 public void EnumerateMetafile(Metafile metafile, Point[] destPoints, Rectangle srcRect, GraphicsUnit unit, EnumerateMetafileProc callback, IntPtr callbackData, ImageAttributes imageAttr)
 {
     throw null;
 }
Example #8
0
 public void DrawImage(Image image, Point[] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr)
 {
     throw null;
 }
 public void DrawImage(Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
 {
     if (image == null)
     {
         throw new ArgumentNullException("image");
     }
     throw new NotImplementedException();
     //Status status = GDIPlus.GdipDrawImageRectRect (nativeObject, image.NativeObject,
     //                  destRect.X, destRect.Y, destRect.Width, destRect.Height,
     //	srcX, srcY, srcWidth, srcHeight, srcUnit,
     //	imageAttrs != null ? imageAttrs.NativeObject : IntPtr.Zero, callback, callbackData);
     //GDIPlus.CheckStatus (status);
 }
Example #10
0
        /// <include file='doc\Bitmap.uex' path='docs/doc[@for="Bitmap.MakeTransparent1"]/*' />
        /// <devdoc>
        ///    Makes the specified color transparent
        ///    for this <see cref='System.Drawing.Bitmap'/>.
        /// </devdoc>
        public void MakeTransparent(Color transparentColor)
        {
            if (RawFormat.Guid == ImageFormat.Icon.Guid)
            {
                throw new InvalidOperationException(SR.Format(SR.CantMakeIconTransparent));
            }

            Size size = Size;

            // The new bitmap must be in 32bppARGB  format, because that's the only
            // thing that supports alpha.  (And that's what the image is initialized to -- transparent)
            Bitmap   result   = null;
            Graphics graphics = null;

            try
            {
                result = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppArgb);
                try
                {
                    graphics = Graphics.FromImage(result);
                    graphics.Clear(Color.Transparent);
                    Rectangle rectangle = new Rectangle(0, 0, size.Width, size.Height);

                    ImageAttributes attributes = null;
                    try
                    {
                        attributes = new ImageAttributes();
                        attributes.SetColorKey(transparentColor, transparentColor);
                        graphics.DrawImage(this, rectangle,
                                           0, 0, size.Width, size.Height,
                                           GraphicsUnit.Pixel, attributes, null, IntPtr.Zero);
                    }
                    finally
                    {
                        if (attributes != null)
                        {
                            attributes.Dispose();
                        }
                    }
                }
                finally
                {
                    if (graphics != null)
                    {
                        graphics.Dispose();
                    }
                }

                // Swap nativeImage pointers to make it look like we modified the image in place
                IntPtr temp = nativeImage;
                nativeImage        = result.nativeImage;
                result.nativeImage = temp;
            }
            finally
            {
                if (result != null)
                {
                    result.Dispose();
                }
            }
        }
        public void DrawImage(Image image, Rectangle destRect, int srcX, int srcY, int srcWidth, int srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            DrawImage(image, destRect, (float)srcX, (float)srcY, (float)srcWidth, (float)srcHeight, srcUnit, imageAttr);
        }
        public void DrawImage(Image image, Rectangle destRect, float srcX, float srcY, float srcWidth, float srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            var srcRect1 = new RectangleF(srcX, srcY, srcWidth, srcHeight);

            // If the source units are not the same we need to convert them
            // The reason we check for Pixel here is that our graphics already has the Pixel's baked into the model view transform
            if (srcUnit != graphicsUnit && srcUnit != GraphicsUnit.Pixel)
            {
                ConversionHelpers.GraphicsUnitConversion(srcUnit, graphicsUnit, image.HorizontalResolution, image.VerticalResolution, ref srcRect1);
            }

            if (image.NativeCGImage == null)
            {
                DrawImage(image, destRect);
                return;
            }

            // Obtain the subImage
            var subImage = image.NativeCGImage.WithImageInRect(new CGRect(srcRect1.X, srcRect1.Y, srcRect1.Width, srcRect1.Height));

            // If we do not have anything to draw then we exit here
            if (subImage.Width == 0 || subImage.Height == 0)
            {
                return;
            }

//			var transform = image.imageTransform;
////			// Reset our height on the transform to account for subImage
//			transform.y0 = subImage.Height;
////
////			// Make sure we scale the image in case the source rectangle
////			// overruns our subimage bouncs width and/or height
//			float scaleX = subImage.Width/srcRect1.Width;
//			float scaleY = subImage.Height/srcRect1.Height;
//			transform.Scale (scaleX, scaleY);

            bool resetAlpha = false;

            if (imageAttrs != null)
            {
                if (!imageAttrs.isGammaSet && imageAttrs.isColorMatrixSet && IsAlphaOnlyColorMatrix(imageAttrs.colorMatrix))
                {
                    resetAlpha = true;
                    context.SetAlpha(imageAttrs.colorMatrix.Matrix33);
                }
                else if (imageAttrs.isColorMatrixSet || imageAttrs.isGammaSet)
                {
                    InitializeImagingContext();
                    CIImage result = subImage;

                    if (imageAttrs.isColorMatrixSet)
                    {
                        var ciFilter = CIFilter.FromName("CIColorMatrix");
                        ciFilter.SetDefaults();

                        ciFilter.SetValueForKey(result, new NSString("inputImage"));

                        var inputRVector    = new CIVector(imageAttrs.colorMatrix.Matrix00, imageAttrs.colorMatrix.Matrix01, imageAttrs.colorMatrix.Matrix02, imageAttrs.colorMatrix.Matrix03);
                        var inputGVector    = new CIVector(imageAttrs.colorMatrix.Matrix10, imageAttrs.colorMatrix.Matrix11, imageAttrs.colorMatrix.Matrix12, imageAttrs.colorMatrix.Matrix13);
                        var inputBVector    = new CIVector(imageAttrs.colorMatrix.Matrix20, imageAttrs.colorMatrix.Matrix21, imageAttrs.colorMatrix.Matrix22, imageAttrs.colorMatrix.Matrix23);
                        var inputAVector    = new CIVector(imageAttrs.colorMatrix.Matrix30, imageAttrs.colorMatrix.Matrix31, imageAttrs.colorMatrix.Matrix32, imageAttrs.colorMatrix.Matrix33);
                        var inputBiasVector = new CIVector(imageAttrs.colorMatrix.Matrix40, imageAttrs.colorMatrix.Matrix41, imageAttrs.colorMatrix.Matrix42, imageAttrs.colorMatrix.Matrix43);

                        ciFilter.SetValueForKey(inputRVector, new NSString("inputRVector"));
                        ciFilter.SetValueForKey(inputGVector, new NSString("inputGVector"));
                        ciFilter.SetValueForKey(inputBVector, new NSString("inputBVector"));
                        ciFilter.SetValueForKey(inputAVector, new NSString("inputAVector"));
                        ciFilter.SetValueForKey(inputBiasVector, new NSString("inputBiasVector"));
                        result = (CIImage)ciFilter.ValueForKey(new NSString("outputImage"));
                    }

                    if (imageAttrs.isGammaSet)
                    {
                        var ciFilter = CIFilter.FromName("CIGammaAdjust");
                        ciFilter.SetDefaults();

                        ciFilter.SetValueForKey(result, new NSString("inputImage"));

                        var inputPower = NSNumber.FromFloat(imageAttrs.gamma);

                        ciFilter.SetValueForKey(inputPower, new NSString("inputPower"));
                        result = (CIImage)ciFilter.ValueForKey(new NSString("outputImage"));
                    }

                    subImage = ciContext.CreateCGImage(result, result.Extent);
                }
            }

            var transform = image.imageTransform;

            transform.y0 = subImage.Height;
            float scaleX1 = subImage.Width / srcRect1.Width;
            float scaleY1 = subImage.Height / srcRect1.Height;

            transform.Scale(scaleX1, scaleY1);
            // Now draw our image
            DrawImage(destRect, subImage, transform);

            if (resetAlpha)
            {
                context.SetAlpha(1.0f);
            }
        }
 public void DrawImage(Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback, int callbackData)
 {
     //Status status = GDIPlus.GdipDrawImagePointsRect (nativeObject, image.NativeObject,
     //	destPoints, destPoints.Length , srcRect.X, srcRect.Y,
     //	srcRect.Width, srcRect.Height, srcUnit,
     //	imageAttr != null ? imageAttr.NativeObject : IntPtr.Zero, callback, (IntPtr) callbackData);
     //GDIPlus.CheckStatus (status);
     throw new NotImplementedException();
 }
 public void DrawImage(Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback)
 {
     DrawImage(image, destPoints, srcRect, srcUnit, imageAttr, callback, 0);
 }
 public void DrawImage(Image image, Point [] destPoints, Rectangle srcRect, GraphicsUnit srcUnit,
                       ImageAttributes imageAttr)
 {
     DrawImage(image, destPoints, srcRect, srcUnit, imageAttr, null, 0);
 }