Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace particular color of image in iOS

I want to replace the particular color of an image with other user selected color. While replacing color of image, I want to maintain the gradient effect of that original color. for example see the attached images. image1.png
image2.png

I have tried to do so with CoreGraphics & I got success to replace color. But the replacing color do not maintain the gradient effect of the original color in the image.

Can someone help me on this? Is the CoreGraphics is right way to do this? Thanks in advance.

like image 219
Er. Mayur Sharma Avatar asked Jan 29 '13 11:01

Er. Mayur Sharma


1 Answers

After some struggling almost with the same problem (but with NSImage), made a category for replacing colors in NSImage which uses ColorCube CIFilter.

https://github.com/braginets/NSImage-replace-color

inspired by this code for UIImage (also uses CIColorCube): https://github.com/vhbit/ColorCubeSample

like image 129
Eugene Braginets Avatar answered Sep 22 '22 15:09

Eugene Braginets