CGImageCreateWithMaskingColors leaves border when color is removed

I use the following code to make magenta transparent:

UIImage *inputImage = [UIImage imageWithData:UIImageJPEGRepresentation(anchorWithMask, 1.0)]; const float colorMasking[6] = {0.0, 255.0, 0.0, 2.0, 0.0, 255.0}; CGImageRef imageRef = CGImageCreateWithMaskingColors(inputImage.CGImage, colorMasking); UIImage *image = [UIImage imageWithCGImage:imageRef]; // add an alpha channel to the image. 

The result is an image with purple borders: http://i.imgur.com/4g6lM.png . Boundaries are present before adding an alpha channel, so it is not associated with this.

Is it possible to get rid of these boundaries?

+4
source share
2 answers

The problem was the mask I'm building. Set emergency settings to fix the problem.

0
source
 CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), NO); 

It will be okay.

+3
source

Source: https://habr.com/ru/post/1383789/


All Articles