ios - drawInRect: losing Quality of Image resolution -
ios - drawInRect: losing Quality of Image resolution -
i trying erase image using next code
cgcolorref strokecolor = [uicolor whitecolor].cgcolor; uigraphicsbeginimagecontext(imgforeground.frame.size); cgcontextref context = uigraphicsgetcurrentcontext(); [imgforeground.image drawinrect:cgrectmake(0, 0, imgforeground.frame.size.width, imgforeground.frame.size.height)]; cgcontextsetlinecap(context, kcglinecapround); cgcontextsetlinewidth(context, 10); cgcontextsetstrokecolorwithcolor(context, strokecolor); cgcontextsetblendmode(context, kcgblendmodeclear); cgcontextbeginpath(context); cgcontextmovetopoint(context, lastpoint.x, lastpoint.y); cgcontextaddlinetopoint(context, currentpoint.x, currentpoint.y); cgcontextstrokepath(context); imgforeground.image = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext();
but find out image losing resolution due drawinrect.
you should go uigraphicsbeginimagecontextwithoptions
instead of uigraphicsbeginimagecontext
, scale factor can specified.
for example, utilize scale factor of device's main screen:
uigraphicsbeginimagecontextwithoptions(imgforeground.frame.size, no, 0);
ios cocoa-touch uiimage quartz-graphics cgcontext
Comments
Post a Comment