在iOS中替换图像的特定颜色 [英] Replace particular color of image in iOS

查看:15
本文介绍了在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.

我曾尝试使用 CoreGraphics &我成功更换了颜色.但是替换颜色并没有保持图像中原始颜色的渐变效果.

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.

有人可以帮我解决这个问题吗?CoreGraphics 是正确的方法吗?提前致谢.

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

推荐答案

在经历了几乎相同的问题(但使用 NSImage)后,在使用 ColorCube CIFilter 的 NSImage 中创建了一个用于替换颜色的类别.

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

受此 UIImage 代码的启发(也使用 CIColorCube):https://github.com/vhbit/ColorCubeSample

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

这篇关于在iOS中替换图像的特定颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆