ios - Add Images from Array to ImageView -
im trying undo function paint app in ios. approach after each drawing (lines, straight lines, squares, circles), drawing added array can pop/remove lastobjectindex of array on undo , repaint contents of array image view. using nsmutablearray , uiimage , use uigraphicsgetimagefromcurrentimagecontext. question is, how can display image arrays 1 uiimageview?
here code:
imgarray = [[nsmutablearray alloc] init]; uiimage *tempimg = [[uiimage alloc] init]; tempimg = uigraphicsgetimagefromcurrentimagecontext(); [imgarray addobject:tempimg]; uigraphicsendimagecontext(); uigraphicsbeginimagecontext(mainimage.frame.size); [mainimage.image drawinrect:cgrectmake(0, 0, self.view.frame.size.width, self.view.frame.size.height) blendmode:kcgblendmodenormal alpha:1.0]; [tempimage.image drawinrect:cgrectmake(0, 0, self.view.frame.size.width, self.view.frame.size.height) blendmode:kcgblendmodenormal alpha:opacity]; mainimage.image = tempimg; //uigraphicsgetimagefromcurrentimagecontext(); tempimage.image = nil; uigraphicsendimagecontext();
as understand it, model graphics app initial background , stack of layers, each layer having object or objects on it.
if so, saved images represent stack. keep temp image representing n-1 of stack, current image, make rendering go faster. in fact, have temp image in view , current active object in different view overtop temp one.
when have undo, can first erase current active object. second undo force re-render temp pict starting @ image 0 , drawing each layer on base image. makes work each layer transparent except drawn bits.
to create temp image, i'd use bitmap context , apply layers in code, unsure if quartz methods or not (they may).
Comments
Post a Comment