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); }
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); }
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)); }
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)); }
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())); } } }
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); }
public QuartzBlendingView() : base() { SourceColor = UIColor.White; DestinationColor = UIColor.Black; BlendMode = CGBlendMode.Normal; }
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); }
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); }
public static extern void RectFrameUsingBlendMode(CGRect rect, CGBlendMode blendMode);
public void SetBlendMode(CGBlendMode mode) { CGContextSetBlendMode(handle, mode); }
public void SetBlendMode (CGBlendMode mode) { CGContextSetBlendMode (handle, mode); }
public virtual void DrawInRect(CGRect rect, CGBlendMode blendMode, CGFloat alpha) { }
public virtual void DrawAtPoint(CGPoint point, CGBlendMode blendMode, CGFloat alpha) { }
extern static void CGContextSetBlendMode(/* CGContextRef */ IntPtr c, CGBlendMode mode);
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)); }
public void SetBlendMode (CGBlendMode mode) { context.CGContext.SetBlendMode (mode); }
extern static void CGContextSetBlendMode(IntPtr context, CGBlendMode mode);
public void SetBlendMode(CGBlendMode mode) { context.CGContext.SetBlendMode(mode); }
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; }
public virtual void FillWithBlendMode(CGBlendMode blendMode, CGFloat alpha) { }
public virtual void StrokeWithBlendMode(CGBlendMode blendMode, CGFloat alpha) { }
public extern static void RectFrameUsingBlendMode(CGRect rect, CGBlendMode blendMode);
public QuartzBlendingView () : base () { SourceColor = UIColor.White; DestinationColor = UIColor.Black; BlendMode = CGBlendMode.Normal; }
// // 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(); }
extern static void CGContextSetBlendMode (/* CGContextRef */ IntPtr c, CGBlendMode mode);