xamarin.ios - Draw into UIImage -


How can I use a current UIImage monotouch?

I load an image: UIImage.FromFile ("MyImage.png")

Then I want to draw a string and some lines in this image.

Do anyone have a code sample?

Thoox

Here's a way to do it:

  Extract from Private Zerochoch (object data) {UITouch Touch = Data as UTT; If (touch! Empty) {UIGraphics.BeginImageContext (this.Image == empty? This.Frame.Size: this.Image.Size); (Using the CGContext cont = UIGraphics.GetCurrentContext ()) {if (This.Image! = Null) {cont.TranslateCTM (0f, this.image.Size.Height); Cont.ScaleCTM (1.0 F, -1.0F); Cont.DrawImage (new RectangleF (0f, 0f, this.Image.Size.Width, this.Image.Size.Height), this image.CGImage); Cont.ScaleCTM (1.0 F, -1.0F); Cont.TranslateCTM (0f, -this.image.Size.Height); } // end if point = last location = touch. Previous Location: View (this); PointF pt = touch. Place invoice (this); (CGPath path = using new CGPath ()) (cont.SetLineCap (CGLineCap.Round); cont.SetLineWidth (3); Cont.SetRGBStrokeColor (0, 2, 3, 1); Path.MoveToPoint (last place. X, the last place. Y); Pth.adlains (new Pointf [] (new Point (final position. X, the final location. y), new Pointf (Piti.aks, Pitikai)}); PathkCloseSubpath () ; using cont.AddPath (path); cont.DrawPath (CGPathDrawingMode.FillStroke); This.Image = UIGraphics.GetImageFromCurrentImageContext ();} // end of the path} // cont UIGraphics.EndImageContext (use); this .SetNeedsDisplay ();} // end if} // end void drawOnTouch   

If you sub UIImageView this method Are in-square and call it Tcbegan and touch, when you touch the screen image.

Comments