-(void) DrawLine: (cgpoint) frompnt topoint: (cgpoint) topnt{
float XScale = theimageview.image.size.width/theimageview.frame.size.width;
float Yscale = theimageview.image.size.height/theimageview.frame.size.height;
Uigraphicsbeginimagecontext (theImageView.image.size);
[Theimageview.image drawinrect:cgrectmake (0, 0, TheImageView.image.size.width, theImageView.image.size.height)];
Cgcontextsetlinecap (Uigraphicsgetcurrentcontext (), kcglinecapsquare);
Cgcontextsetlinewidth (Uigraphicsgetcurrentcontext (), 2.0*[self Returnmax:xscale Withnumber:yscale]);
Cgcontextsetallowsantialiasing (Uigraphicsgetcurrentcontext (), YES);
Cgcontextsetrgbstrokecolor (Uigraphicsgetcurrentcontext (), 1.0, 0.0, 0.0, 1.0);
Cgcontextbeginpath (Uigraphicsgetcurrentcontext ());
Cgcontextmovetopoint (Uigraphicsgetcurrentcontext (), Frompnt.x*xscale, Frompnt.y*yscale);
Cgcontextaddlinetopoint (Uigraphicsgetcurrentcontext (), Topnt.x*xscale, Topnt.y*yscale);
Cgcontextstrokepath (Uigraphicsgetcurrentcontext ());
Theimageview.image=uigraphicsgetimagefromcurrentimagecontext ();
Uigraphicsendimagecontext ();
}
This article is from the "zhuoking" blog, make sure to keep this source http://9951038.blog.51cto.com/9941038/1772572
Drawing lines for iOS image processing