更改UIImage中的颜色 [英] Change a color in a UIImage

查看:149
本文介绍了更改UIImage中的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何只改变图片中的一种颜色。
像说:如果这个像素中的颜色是红色,则将其更改为蓝色。

I will like to know how I can change just one color in a image. Like saying: if the color in this pixel is "red" change it to "blue".

推荐答案

技术方法很简单:


  1. 获取所有像素值(解释此处

  2. 查找像素

  3. 使用已更改的像素值绘制图片(解释此处

  1. get all pixel values (explained here)
  2. Look for the pixel values you don't like and change them
  3. Draw the image using the changed pixel values (explained here)

,如果将三个步骤混合到一个方法中,而不创建UIColor对象,但更改它们,然后立即绘制更改的图像,您将获得更好的性能。

Keep in mind, if you mix the three steps into one method, without creating UIColor objects but changing them and immediately afterwards drawing the changed image, you'll get much better performance.

这篇关于更改UIImage中的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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