IOS transparency

I have an image that I took with my iOS device that contains a few lines of words and a little background color (red). I want the image to display only words to the user (they will do something similar). I cannot use UIImageView in any way, so just taking the image and setting it to the background will not work.

So I was wondering if anyone could tell me which of the following methods would give me the best results, if possible, and the example would be nice. I posted the code below what I tried to do with a little luck (option 2).

  • Make the background white so that only words are displayed.
  • Remove red from image

Thank you in advance

UIImage *image = [UIImage imageNamed:@"pic1.jpg"]; const float colorMasking[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; image = [UIImage imageWithCGImage: CGImageCreateWithMaskingColors(image.CGImage, colorMasking)]; 
+2
source share
1 answer
 UIImage *image = [UIImage imageNamed:@"image1.jpg"]; UIImage *inputImage = [UIImage imageWithData:UIImageJPEGRepresentation(image, 1.0)]; const float colorMasking[6] = {225.0, 255.0, 225.0, 255.0, 225.0, 255.0}; CGImageRef imageRef = CGImageCreateWithMaskingColors(inputImage.CGImage, colorMasking); UIImage *img2 = [UIImage imageWithCGImage:imageRef]; 

I removed the light gray color from the background of my image. Color range from 225 to 255 for RGB. Now it looks transparent.

+2
source

All Articles