Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Shinji-23

macrumors newbie
Original poster
Dec 18, 2008
2
0
I was planning on using a non-displayed image for hit detection by getting the color of the image at the point corresponding to the touch. I can't seem to find anyway to do this in the iPhone SDK.

Does anybody know of an equivalent of NSBitmapImageRep's colorAtX:y:?
 

firewood

macrumors G3
Jul 29, 2003
8,141
1,384
Silicon Valley
If you have a pointer to the raw bitmap, and know the bytes-per-row and bytes-per-pixel, then it's a couple multiplies and an add to get a pointer to the raw pixel data from an X,Y coordinate.


.
 

Shinji-23

macrumors newbie
Original poster
Dec 18, 2008
2
0
If you have a pointer to the raw bitmap...

How do you get at that? Would that be CGImageGetDataProvider(image.CGImage)? Even if it is, do I have to realize that it's a PNG backing and code up the PNG reading standard to get at my color?

(And if it is, how do I get data out of the CGDataProviderRef?)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.