views:

246

answers:

2

I've got an Info Button (Dark) which overlays a UIImageView photograph (which the user makes with camera).

The trouble is, if the photo is dark, then the button is almost invisible (because it's dark too). So, is there a way to get the color of the part of the image under the info button, so that I can change the info button to either dark or light?

+1  A: 

Please take a look:
sample 1 (What Color is My Pixel? Image based color picker on iPhone)

You will have RGB data for each pixel.. and you may analyse dark it or bright.

or sample 2 (Apple)

MikZ
A: 

A better solution would be to have your designer come up with a button that looks good on dark and light backgrounds using an outline and gloss or something like that. It might look weird to switch between light and dark depending on the image.

But yeah, CGDataProviderCopyData(CGImageGetDataProvider(inImage)) will do the trick to get the image pixels data.

Andrew Pouliot