views:

302

answers:

2

I want to get the color of the Pixel at a specific Touch Point on an EAGLView. Is this possible, and if so, how?

A: 

You should be able to get the raw bitmap data using something similar to what is used in this question. From there, you can extract the byte values for the color elements at the point the touch occurred.

Brad Larson
Thank you. This helped.
RexOnRoids
You might consider using the code in my answer instead, since it does exactly what you want instead of reading all pixels copy them to a bitmap context and later decide to read one pixel from there.The code in the example quoted here is surely a million times slower.
nschmidt
+5  A: 

You can read a pixel with

unsigned int pixel;
glReadPixels( x, y, 1, 1, GL_RGBA, GL_UNSIGNED_INT, &pixel);

Depending on the format of your framebuffer you may have to use different values for the format and type parameters.

nschmidt