Filipe Mota
Filipe Mota

Reputation: 350

Change a color in a 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".

Upvotes: 1

Views: 2455

Answers (1)

Pascal
Pascal

Reputation: 16941

The technical approach is straightforward:

  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)

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.

Upvotes: 4

Related Questions