Saturday, 15 September 2012

ios - Transparent Pixels on bottom corners of UIImage? -


I am trying to make my image transparent down the corner so that a face curved form can be supported. I have tried with the following code but CGPathAddArc is a bit confusing because I am not much of math. The red corner shown in the image defines the area that I want to make transparent.

what do i have

 I want to make red line size transparent

  UIGraphicsBeginImageContext (originalImage.size); [Original Image Drawpointpoint: CGPanzero]; CGMutablePathRef testRef = CGPathCreateMutable (); // CGAffineTransform temp = CGPhen Transcend Mekotation (M_PI / 2); // CGPathAddEllipseInRect (testRef, and temp, CGRectMake (0,0,20,20)); // CGPathAddQuadCurveToPoint (testRef, zero, 20, 20, 150, 150); // CGPathAddCurveToPoint (testRef, NULL, 20, 20, 40, 40, 100, 100); CGPathMoveToPoint (testRef, NULL, 20, 20); CGPathAddArc (testRef, NULL, 0, 15, 15, M_PI_2, -M_PI_2, true); // Clip to the path and clear that part of the image. CGContextRef Reference = UIGraphicsGetCurrentContext (); CGContextAddPath (reference, testRef); CGContextClip (reference); CGContextClearRect (Reference, CGRectMake (0,0, originalImage.size.width, originalImage.size.height)); // Create a new UIImage image reference from UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext (); UIGraphicsEndImageContext ();    

If you are not familiar with basic-foundation and low-level stuff, you Accessibility [UIBezierPath bezierPathWithRoundedRect: byRoundingCorners: cornerRadii:] Find a rectangle with rounded corners.

Example:

  UIGraphicsBeginImageContext (Original Image.size); UIBezierPath * Path = [UIBezierPath bezierPathWithRoundedRect: CGRectMake (0, 0, originalImage.size.width, originalImage.size.height) byRoundingCorners: UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii: CGSizeMake (15, 15)]; [Path adclip]; [Original Image Drawpointpoint: CGPanzero]; UIImage * newImage = UIGraphicsGetImageFromCurrentImageContext (); UIGraphicsEndImageContext ();    

No comments:

Post a Comment