2

I have an image with transparence background, for example image.

I need to create many images with different color and I want to use this one image and multiply it with color for create some other images, for example new image.

Could you please help me with some lines of code. Thanks.

Rubycon
  • 18,156
  • 10
  • 49
  • 70
  • possible duplicate of [How to tint a transparent PNG image in iPhone?](http://stackoverflow.com/questions/3514066/how-to-tint-a-transparent-png-image-in-iphone) – John Parker May 08 '11 at 15:39
  • Please check for existing answers before you ask a new question. :-) – John Parker May 08 '11 at 15:39

1 Answers1

2

This might help:

UIImage *beginUIImage = [UIImage imageNamed:@"myImage.png"];

CIImage *beginImage = [CIImage imageWithCGImage:beginUIImage.CGImage];    

CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone" 
                              keysAndValues: kCIInputImageKey, beginImage, 
                    @"inputIntensity", [NSNumber numberWithFloat:0.8], nil];

CIImage *outputImage = [filter outputImage];    

UIImage *endImage = [[UIImage alloc] initWithCIImage:outputImage];

The beginUIImage is the initial transparent image. Then I change it into a CIImage to ease the process of applying filters. Then I apply a Sepia filter to the image. Then I output the image with a filter applied into another CIImage called outputImage. Lastly, I change the outputImage into a UIImage to be used later, perhaps put into a UIImageView, perhaps saved into the Photo library. You can change the type of filter to change the output images' colors.

pasawaya
  • 11,515
  • 7
  • 53
  • 92