示例#1
0
 public static UIImage AdjustImage(UIImage template, CGBlendMode mode,UIColor color)
 {
     float red = new float();
     float green = new float();
     float blue = new float();
     float alpha = new float();
     if (color == null)
         color = UIColor.FromRGB(100,0,0);
     color.GetRGBA(out red,out green, out blue, out alpha);
     return 	AdjustImage(new RectangleF(PointF.Empty,template.Size),template,mode,red,green,blue,alpha);
 }
示例#2
0
 public static UIImage AdjustImage(RectangleF rect,UIImage template, CGBlendMode mode,UIColor color)
 {
     if(color == null)
         return template;
     float red = new float();
     float green = new float();
     float blue = new float();
     float alpha = new float();
     if (color == null)
         color = UIColor.FromRGB(100,0,0);
     color.GetRGBA(out red,out green, out blue, out alpha);
     return 	AdjustImage(rect,template,mode,red,green,blue,alpha);
 }
示例#3
0
        public static UIImage AdjustImage(CGRect rect, UIImage template, CGBlendMode mode, UIColor color)
        {
            nfloat red   = new float();
            nfloat green = new float();
            nfloat blue  = new float();
            nfloat alpha = new float();

            if (color == null)
            {
                color = UIColor.FromRGB(100, 0, 0);
            }
            color.GetRGBA(out red, out green, out blue, out alpha);
            return(AdjustImage(rect, template, mode, red, green, blue, alpha));
        }
示例#4
0
        public static UIImage AdjustImage(UIImage template, CGBlendMode mode, UIColor color)
        {
            float red   = new float();
            float green = new float();
            float blue  = new float();
            float alpha = new float();

            if (color == null)
            {
                color = UIColor.FromRGB(100, 0, 0);
            }
            color.GetRGBA(out red, out green, out blue, out alpha);
            return(AdjustImage(new RectangleF(PointF.Empty, template.Size), template, mode, red, green, blue, alpha));
        }
示例#5
0
 public static UIImage AdjustImage(CGRect rect, UIImage template, CGBlendMode mode, nfloat red, nfloat green, nfloat blue, nfloat alpha)
 {
     using (var cs = CGColorSpace.CreateDeviceRGB()) {
         using (var context = new CGBitmapContext(IntPtr.Zero, (int)rect.Width, (int)rect.Height, 8, (int)rect.Height * 4, cs, CGImageAlphaInfo.PremultipliedLast)) {
             context.TranslateCTM(0.0f, 0f);
             //context.ScaleCTM(1.0f,-1.0f);
             context.DrawImage(rect, template.CGImage);
             context.SetBlendMode(mode);
             context.ClipToMask(rect, template.CGImage);
             context.SetFillColor(red, green, blue, alpha);
             context.FillRect(rect);
             return(UIImage.FromImage(context.ToImage()));
         }
     }
 }
示例#6
0
        public static UIImage AdjustImage(RectangleF rect,UIImage template, CGBlendMode mode,float red,float green,float blue,float alpha )
        {
            using (var cs = CGColorSpace.CreateDeviceRGB ()){
                using (var context = new CGBitmapContext (IntPtr.Zero, (int)rect.Width, (int)rect.Height, 8, (int)rect.Height*8, cs, CGImageAlphaInfo.PremultipliedLast)){

                    context.SetShadowWithColor(new SizeF(0.0f, 1.0f), 0.7f, UIColor.Black.CGColor);
                    context.TranslateCTM(0.0f,0f);
                    //context.ScaleCTM(1.0f,-1.0f);
                    context.DrawImage(rect,template.CGImage);
                    context.SetBlendMode(mode);
                    context.ClipToMask(rect,template.CGImage);
                    context.SetRGBFillColor(red,green,blue,alpha);
                    context.FillRect(rect);

                    return UIImage.FromImage (context.ToImage ());
                }
            }
        }
        public static UIImage Tint(this UIImage img, UIColor tint, CGBlendMode blendMode)
        {
            UIGraphics.BeginImageContextWithOptions(img.Size, false, 0f);
            tint.SetFill();
            var bounds = new RectangleF(0, 0, img.Size.Width, img.Size.Height);

            UIGraphics.RectFill(bounds);

            img.Draw(bounds, blendMode, 1f);

            if (blendMode != CGBlendMode.DestinationIn)
            {
                img.Draw(bounds, CGBlendMode.DestinationIn, 1f);
            }

            var tintedImage = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            return(tintedImage);
        }
示例#8
0
 public QuartzBlendingView() : base()
 {
     SourceColor      = UIColor.White;
     DestinationColor = UIColor.Black;
     BlendMode        = CGBlendMode.Normal;
 }
示例#9
0
        public static UIImage Blend(this UIImage image, nfloat alpha, CGColor fillColor, CGBlendMode blendMode = CGBlendMode.Normal)
        {
            UIGraphics.BeginImageContextWithOptions(image.Size, false, 0);

            var rect = new CGRect(0, 0, image.Size.Width, image.Size.Height);

            if (fillColor != null)
            {
                var context = UIGraphics.GetCurrentContext();
                context.SetFillColor(fillColor);
                context.FillRect(rect);
            }

            image.Draw(rect, blendMode, alpha);

            var newImage = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            return(newImage);
        }
示例#10
0
 public static UIImage AdjustImage(UIImage template, CGBlendMode mode,float red,float green,float blue,float alpha )
 {
     return AdjustImage(new RectangleF(PointF.Empty,template.Size),template,mode,red,green,blue,alpha);
 }
示例#11
0
 public static extern void RectFrameUsingBlendMode(CGRect rect, CGBlendMode blendMode);
示例#12
0
 public void SetBlendMode(CGBlendMode mode)
 {
     CGContextSetBlendMode(handle, mode);
 }
示例#13
0
		public void SetBlendMode (CGBlendMode mode)
		{
			CGContextSetBlendMode (handle, mode);
		}
示例#14
0
 public virtual void DrawInRect(CGRect rect, CGBlendMode blendMode, CGFloat alpha)
 {
 }
示例#15
0
 public virtual void DrawAtPoint(CGPoint point, CGBlendMode blendMode, CGFloat alpha)
 {
 }
示例#16
0
 extern static void CGContextSetBlendMode(/* CGContextRef */ IntPtr c, CGBlendMode mode);
示例#17
0
 public static UIImage AdjustImage(UIImage template, CGBlendMode mode, float red, float green, float blue, float alpha)
 {
     return(AdjustImage(new RectangleF(PointF.Empty, template.Size), template, mode, red, green, blue, alpha));
 }
示例#18
0
		public void SetBlendMode (CGBlendMode mode) {
			context.CGContext.SetBlendMode (mode);
		}
示例#19
0
		extern static	void CGContextSetBlendMode(IntPtr context, CGBlendMode mode);
示例#20
0
 public void SetBlendMode(CGBlendMode mode)
 {
     context.CGContext.SetBlendMode(mode);
 }
示例#21
0
        public static UIImage Tint(this UIImage img, UIColor tint, CGBlendMode blendMode) {
            UIGraphics.BeginImageContextWithOptions(img.Size, false, 0f);
            tint.SetFill();
            var bounds = new CGRect(0, 0, img.Size.Width, img.Size.Height);
            UIGraphics.RectFill(bounds);

            img.Draw(bounds, blendMode, 1f);

            if (blendMode != CGBlendMode.DestinationIn)
                img.Draw(bounds, CGBlendMode.DestinationIn, 1f);

            var tintedImage = UIGraphics.GetImageFromCurrentImageContext();
            UIGraphics.EndImageContext();

            return tintedImage;
        }
示例#22
0
 public virtual void FillWithBlendMode(CGBlendMode blendMode, CGFloat alpha)
 {
 }
示例#23
0
 extern static void CGContextSetBlendMode(IntPtr context, CGBlendMode mode);
示例#24
0
 public virtual void StrokeWithBlendMode(CGBlendMode blendMode, CGFloat alpha)
 {
 }
示例#25
0
 public extern static void RectFrameUsingBlendMode(CGRect rect, CGBlendMode blendMode);
		public QuartzBlendingView () : base () {
			SourceColor = UIColor.White;
			DestinationColor = UIColor.Black;
			BlendMode = CGBlendMode.Normal;
		}
示例#27
0
        //
        // Helper function to generate shadow
        //
        private void GenerateShapeShadow(CGContext context, UIBezierPath shapeObject, nfloat xOffset, nfloat yOffset, nfloat blurValue, CGBlendMode blendingMode, UIColor shadowColor, nfloat borderWidth, int borderPosition, nfloat iWidth, nfloat iHeight)
        {
            CGPoint basePoint;
            CGPoint offsetPoint;
            CGSize  calculatedShadowOffset;
            nfloat  calculatedShadowBlur;
            CGPoint constPointZero;

            constPointZero = new CGPoint(0, 0);

            basePoint              = baseTransform.TransformPoint(context.PointToDeviceSpace(constPointZero));
            offsetPoint            = baseTransform.TransformPoint(context.PointToDeviceSpace(new CGPoint(xOffset, yOffset)));
            calculatedShadowOffset = new CGSize(offsetPoint.X - basePoint.X, offsetPoint.Y - basePoint.Y);
            if (blurValue == 0)
            {
                calculatedShadowBlur = 0;
            }
            else
            {
                calculatedShadowBlur = Hypot(calculatedShadowOffset.Width, calculatedShadowOffset.Height) / blurValue;
            }
            context.SetShadow(calculatedShadowOffset, calculatedShadowBlur, shadowColor.CGColor);
            context.SetBlendMode(blendingMode);

            context.BeginTransparencyLayer(null);

            UIColor.Black.SetFill();
            shapeObject.Fill();

            if (borderWidth > 0)
            {
                if (borderPosition == 0)
                {
                    context.SaveState();
                    shapeObject.LineWidth = borderWidth;
                    UIColor.Black.SetStroke();
                    shapeObject.Stroke();
                    context.RestoreState();
                }

                if (borderPosition == 1)
                {
                    context.BeginPath();
                    context.AddPath(shapeObject.CGPath);
                    context.EOClip();
                }

                if (borderPosition == 2)
                {
                    context.BeginPath();
                    context.AddPath(shapeObject.CGPath);
                    context.AddRect(RectangleFExtensions.Inset(shapeObject.Bounds, iWidth, iHeight));
                    context.EOClip();
                }
            }

            context.EndTransparencyLayer();
        }
示例#28
0
		extern static void CGContextSetBlendMode (/* CGContextRef */ IntPtr c, CGBlendMode mode);