tags:

views:

73

answers:

2

how to get UIImage Pixel value?

If i clicked on the UIImage it need to display the pixel data.

I draw using mouseMoved event some part on image with red color.

When i clicked on red color drawn part, it need to display color value 1,0,0,1.

Can any one tell me.

Thanks in advance.

+1  A: 

This seems to be a near duplicate question to this one: http://stackoverflow.com/questions/144250/how-to-get-the-rgb-values-for-a-pixel-on-an-image-on-the-iphone

hotpaw2
Thanks @hotpaw2if i draw on my image with Red color ... and i click on my uiimage view to get data... do i get same red color value .... 1,0,0,1.
kiran
You might have to play with the scale factor. 1.0 versus 255 for white.
hotpaw2
can you provided example on scale factor....
kiran
@kiran: Depends on your method of reading pixel values. If white shows up around 255 and you want 1.0 then divide by 255.0 to scale. Or vice versa.
hotpaw2
http://www.markj.net/iphone-uiimage-pixel-color/from the above link...I downloaded the source code. It works good.....When I am trying with different image. I do not getting exact pixel value. What to do to get exact pixel value .....?Thanks in advance....
kiran
What values are you getting? What value do you expect to be the exact correct value? How do you know?
hotpaw2
The RGBA values for pixel....I have an image colored with yellow,red,green,black and white.when iam clicking on yellow color. It displaying white color value. (1 1 1 1 or 255 255 255 255).what to do.?thanks in advance.
kiran
@hotpaw2... I need to set CGRectMake for my image.. It will get the exact pixel value.
kiran
A: 

http://www.markj.net/iphone-uiimage-pixel-color/

from the above link... I downloaded the source code. It works good.....

When I am trying with different image. I do not getting exact pixel value.

What to do to get exact pixel value .....?

Thanks in advance....

kiran