ios - Create image on top of another uiimage -
i not able draw image on top of image. below if code using:
-(void)createimage { // create new bitmap image context @ device resolution (retina/non-retina) uigraphicsbeginimagecontextwithoptions(imgvw_nohair_.frame.size, yes, 0.0); // context cgcontextref context = uigraphicsgetcurrentcontext(); // push context make current // (need manually because not drawing in uiview) uigraphicspushcontext(context); // drawing code comes here- @ cgcontext reference // available operations // example draws inputimage context [eraser drawatpoint:cgpointmake(50, 50)]; // pop context uigraphicspopcontext(); uiimage _image_ = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); }
the image current context black image. want draw eraser image on image context.
this updated code working in side.
-(void)createimage { //create context in have draw uigraphicsbeginimagecontextwithoptions(imgvwimage.image.size, yes, 0.0); // context cgcontextref context = uigraphicsgetcurrentcontext(); // push context make current // (need manually because not drawing in uiview) uigraphicspushcontext(context); //draw old image in context [imgvwimage.image drawinrect:cgrectmake(0, 0, 200, 200)]; uiimage *img=[uiimage imagenamed:@"img.png"]; //draw image in context [img drawatpoint:cgpointmake(50, 50)]; // pop context uigraphicspopcontext(); uiimage *image_ = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); //get image imgvwimage.image=image_; }
Comments
Post a Comment