views:

323

answers:

2

Does anyone know of a way to simply and effectively brighten a UIImage by a specific amount? I am currently fiddling with the Apple Sample Code Example GLImageProcessing with poor results...My app currently does not use OpenGLES or EAGLViews and it is awkward trying to bridge the technology.

+1  A: 

That depends what you mean by "brighten". You can overlay colors easily, and you can probably figure out some blending mode that will do what you want. Look through the CG functions and documentation (I'd post in more detail, but I can't right now).

jtbandes
I guess I would just want to first retrieve the RGB values of each pixel, and then increase the RGB values across pixels that are higher than a certain values, and maybe decrease the RGB values across pixels that are lower. I think the effect would be akin to combined LIGHTEN and ADD CONTRAST operations of a photo editing program.
RexOnRoids
+3  A: 

You could render the UIImage into a CGBitmapContext. And then you should have a pointer to the raw bytes of the image. At that point you could do anything you'd like with the bytes, including brighten them. After that you can create a new CGImageRef from the bytes.

This would all be on the CPU, which might not perform as well as an OpenGL solution depending on the image size.

Jon Hess