3
모노 터치를 사용하면 현재 표시되고있는 UIImage의 이미지에 간단한 선을 그 으려면 어떻게해야합니까?Monotouch UIImage에서 선 그리기
간단한 예는 물론 좋습니다.
Obj-C 답변도 괜찮습니다.
모노 터치를 사용하면 현재 표시되고있는 UIImage의 이미지에 간단한 선을 그 으려면 어떻게해야합니까?Monotouch UIImage에서 선 그리기
간단한 예는 물론 좋습니다.
Obj-C 답변도 괜찮습니다.
당신은 이미지 속성에 설정된 이미지와 사용자 지정 UIImageView에있는 가정, 그것에서이 방법을 배치 :
는private void DrawLineOnImage()
{
UIGraphics.BeginImageContext(this.Image.Size);
using (CGContext cont = UIGraphics.GetCurrentContext())
{
cont.TranslateCTM(0f, this.Image.Size.Height);
cont.ScaleCTM(1.0f, -1.0f);
cont.DrawImage(new RectangleF(0f,0f,this.Image.Size.Width, this.Image.Size.Height), this.Image.CGImage);
cont.ScaleCTM(1.0f, -1.0f);
cont.TranslateCTM(0f, -this.Image.Size.Height);
using (CGPath path = new CGPath())
{
cont.SetLineWidth(3);
cont.SetRGBStrokeColor(255, 0, 0, 1);
path.AddLines(new PointF[] {
new PointF(10, 10),
new PointF(100, 100) });
path.CloseSubpath();
cont.AddPath(path);
cont.DrawPath(CGPathDrawingMode.FillStroke);
this.Image = UIGraphics.GetImageFromCurrentImageContext();
}//end using path
}//end using cont
UIGraphics.EndImageContext();
}//end void DrawLineOnImage
이 이미지 자체에 빨간색 선을 그립니다.