iphone - Crop image in oval shape -
i working on app in need give cropping option. once select image camera or gallery should open on editing page have oval image zooming & moving option. once click on apply captured image should cropped in oval shape.
now following screen aviary sdk. has square cropping & in need cropping in oval shape. tried customise not able so.
can suggest me easiest or best suitable way implement this.
thanks.
- (uiimage *)croppedphoto { // dealing retina displays non-retina, need check // scale factor, if available. note use size of teh cropping rect // passed in, , not size of view taking screenshot of. cgrect croppingrect = cgrectmake(imgmaskimage.frame.origin.x, imgmaskimage.frame.origin.y, imgmaskimage.frame.size.width, imgmaskimage.frame.size.height); imgmaskimage.hidden=yes; if ([[uiscreen mainscreen] respondstoselector:@selector(scale)]) { uigraphicsbeginimagecontextwithoptions(croppingrect.size, yes, [uiscreen mainscreen].scale); } else { uigraphicsbeginimagecontext(croppingrect.size); } // create graphics context , translate view want crop // in grabbing (0,0), origin point represents actual // cropping origin desired: cgcontextref ctx = uigraphicsgetcurrentcontext(); cgcontexttranslatectm(ctx, -croppingrect.origin.x, -croppingrect.origin.y); [self.view.layer renderincontext:ctx]; // retrieve uiimage current image context: uiimage *snapshotimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); // return image in uiimageview: return snapshotimage; }
Comments
Post a Comment