William Jockusch
William Jockusch

Reputation: 27325

iOS -- multiply the R, G, B, and A components of a UIImage object by constants?

Given a UIImage object, I want to programmatically multiply the R, G, B, and A components of its colors by fixed constants. So, for instance, if I choose 1,0,0,1 for my constants, I would basically grab the red component of the image, while discarding the rest.

Is there an easy way to do that?

Upvotes: 0

Views: 410

Answers (1)

Eli
Eli

Reputation: 646

Some quick searching brought up this tutorial:

http://brandontreb.com/image-manipulation-retrieving-and-updating-pixel-values-for-a-uiimage/

From what I can see, that tutorial involves drawing the UIImage onto a buffer in memory, manipulating that buffer, then transferring the pixel data from that back to the UIImage.

Basically, there's no simple way to do that with any of the methods of UIImage.

Upvotes: 1

Related Questions