ios - How to remove the transparent area of an UIImageView after masking? -
in 1 of ios applications, trying cutting portion of image using cgimagemask
. have succeeded in masking image next code:
- (uiimage *)maskimage:(uiimage *)referenceimage withmask:(uiimage *)maskimage { cgimageref maskref = maskimage.cgimage; cgimageref mask = cgimagemaskcreate(cgimagegetwidth(maskref), cgimagegetheight(maskref), cgimagegetbitspercomponent(maskref), cgimagegetbitsperpixel(maskref), cgimagegetbytesperrow(maskref), cgimagegetdataprovider(maskref), null, false); cgimageref masked = cgimagecreatewithmask([referenceimage cgimage], mask); homecoming [uiimage imagewithcgimage:masked]; }
so, image be:
myimageview.image = [self maskimage:[uiimage imagenamed:@"image.png"] withmask:[uiimage imagenamed:@"mask.png"]];
problem: output image of same size of reference image('image.png') transparent area around. want avoid transparent area, , crop result image. how can accomplish this? there several masks, , mask frames not similar all. attaching reference image of problem overview here. please help me friends. in advance.
look auto-cropping uiimage. should crop out transparent.
how autocrop uiimage?
ios objective-c core-graphics masking cgimagemaskcreate
No comments:
Post a Comment