Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS -- detect the color of a pixel?

For example, suppose I want to detect the color of the pixel with screen coordinates (100, 200). Is there a way to do this?

EDIT -- I'm not worried about retina display issues for now.

like image 325
William Jockusch Avatar asked Jan 06 '11 15:01

William Jockusch


People also ask

How can I tell the color of a pixel?

Use the ColorSync Utility calculator to get the color values of a pixel on your screen. In the ColorSync Utility app on your Mac, click Calculator in the toolbar of the ColorSync Utility window. Click the magnifying glass , then move your pointer over an area on the screen that you want to examine.

How do I color match a picture on my iPhone?

Both Benjamin Moore's Ben Color Capture and Sherwin-Williams' ColorSnap work on the same principal: Take a picture with your iPhone or select a photo from your the photo library on your iPhone or iPod touch, crop the photo for the best color selection, then touch or drag your finger across the screen to choose the ...

How do I get the eyedropper on my iPhone?

To get started, tap (or tap-and-hold) the eyedropper icon in the top left of the color picker. The color editor will minimize, and the eyedropper tool will appear, which looks like a circle with a grid of squares inside.

Is there a color finder app?

ColorSnap® Visualizer for iPhone and Android.


1 Answers

This may not be the most direct route, but you could:

  1. Use UIGraphicsBeginImageContextWithOptions to grab the screen (see the Apple Q&A QA1703 - "Screen Capture in UIKit Applications").

  2. Then use CGImageCreateWithImageInRect to grab the portion of the resultant image you require.

  3. Finally analyse the resultant image. It gets complicated at this point, but thankfully there's an existing question that should show you the way: How to get the RGB values for a pixel on an image on the iphone

Alternatively, there's the following blog article that has accompanying code: What Color is My Pixel? Image based color picker on iPhone

like image 129
John Parker Avatar answered Oct 02 '22 03:10

John Parker