objective c - Drawing into a loaded UIImage in iOS -
objective c - Drawing into a loaded UIImage in iOS -
i have couple of questions.
i have loaded uiimage , to:
1st - draw image onto loaded uiimage
2nd - draw line (with color , thickness) onto loaded uiimage
i appreciate if come basic stuff, i'm still noob :)
there's alternative , comes using core-graphics.
uigraphicsbeginimagecontextwithoptions(size, no, 0.0); cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsavegstate(context); uiimage *bottomimage = ...; cgrect bottomimagerect = ...; cgcontextscalectm(context, 1.0, -1.0); cgcontexttranslatectm(context, 0, -bottomimagerect.size.height); cgcontextdrawimage(context, bottomimagerect, bottomimage.cgimage); cgcontextrestoregstate(context); cgcontextsavegstate(context); uiimage *topimage = ...; cgrect topimagerect = ...; cgcontextscalectm(context, 1.0, -1.0); cgcontexttranslatectm(context, 0, -topimagerect.size.height); cgcontextdrawimage(context, topimagerect, topimage.cgimage); cgcontextrestoregstate(context); cgpoint origin = ...; cgpoint end = ...; cgcontextmovetopoint(context, origin.x, origin.y); cgcontextaddlinetopoint(context, end.x, end.y); cgcontextsetstrokecolorwithcolor(context, [uicolor whatever].cgcolor); cgcontextstrokepath(context); uiimage *result = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext();
edit: changed code little images not inverted
ios objective-c image uiimage draw
Comments
Post a Comment