iphone - Remove white background in UIImageView -
i using uibezierpath
draw lines in white background , black stroke using fingers , touch end method cropping image using cggraphicscontext()
, working fine. remove white background , make transparent. have tried several codes , not working me. below code makes entire image transparent. 1 can me make image transparent except black stroke. in advance. sorry if question asked.
-(uiimage*) maketransparent : (uiimage*) viewimage { cgimageref rawimageref = viewimage.cgimage; const float colormasking[6] = {255, 255, 255, 255, 255, 255}; uigraphicsbeginimagecontext(viewimage.size); cgimageref maskedimageref = cgimagecreatewithmaskingcolors(rawimageref, colormasking); cgcontexttranslatectm(uigraphicsgetcurrentcontext(), 0.0, viewimage.size.height); cgcontextscalectm(uigraphicsgetcurrentcontext(), 1.0, -1.0); cgcontextdrawimage(uigraphicsgetcurrentcontext(), cgrectmake(0, 0, viewimage.size.width, viewimage.size.height), maskedimageref); uiimage *newimage = uigraphicsgetimagefromcurrentimagecontext(); cgimagerelease(maskedimageref); uigraphicsendimagecontext(); return newimage; }
you use uiimageview
display uiimage
set backgroundcolor clearcolor
bellow...
[yourimageview setbackgroundcolor:[uicolor clearcolor]];
Comments
Post a Comment