コード例 #1
0
ファイル: Graphics.cs プロジェクト: Clancey/Facetroids
 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
ファイル: Graphics.cs プロジェクト: Clancey/Facetroids
 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
ファイル: iOSTool.cs プロジェクト: Sphere10/Framework
        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
ファイル: iOSTool.cs プロジェクト: Sphere10/Framework
 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
ファイル: Graphics.cs プロジェクト: Clancey/Facetroids
        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 ());
                }
            }
        }
コード例 #7
0
        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
ファイル: Graphics.cs プロジェクト: Clancey/Facetroids
 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
ファイル: CGContext.cs プロジェクト: zezba9000/maccore
 public void SetBlendMode(CGBlendMode mode)
 {
     CGContextSetBlendMode(handle, mode);
 }
コード例 #13
0
ファイル: CGContext.cs プロジェクト: jonlipsky/maccore
		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
ファイル: CGContext.cs プロジェクト: jonlipsky/maccore
		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
ファイル: UIBezierPath.cs プロジェクト: afrog33k/CocoaSharp
 public virtual void FillWithBlendMode(CGBlendMode blendMode, CGFloat alpha)
 {
 }
コード例 #23
0
ファイル: CGContext.cs プロジェクト: zezba9000/maccore
 extern static void CGContextSetBlendMode(IntPtr context, CGBlendMode mode);
コード例 #24
0
ファイル: UIBezierPath.cs プロジェクト: afrog33k/CocoaSharp
 public virtual void StrokeWithBlendMode(CGBlendMode blendMode, CGFloat alpha)
 {
 }
コード例 #25
0
 public extern static void RectFrameUsingBlendMode(CGRect rect, CGBlendMode blendMode);
コード例 #26
0
		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);