Hi all,
I was just wandering if this is possible to do in cocoa.
My target is, make screenshot of the current screen of an iphone or ipad.
Then with a partial colorpicker of the screenshot I want to determine if the device in is the welcome screen or not.
Is there anyone that can help me out with the color picking part ?
If this is possible.. ofcourse.
EDIT: This applies for a mac application, and not an iOS application.
My mac application can make screenshots of an iPhone.
The Mac must scan/colopick background color of these screenshots.
Thanks!
Sollution:
Down here the following code I used in an test environment, with 2 input fields so I can give an NSPoint.
The NSPoint is from bottom left, so I take image height - desired height.
This will get hex color code from image from x,y from topleft.
I was just wandering if this is possible to do in cocoa.
My target is, make screenshot of the current screen of an iphone or ipad.
Then with a partial colorpicker of the screenshot I want to determine if the device in is the welcome screen or not.
Is there anyone that can help me out with the color picking part ?
If this is possible.. ofcourse.
EDIT: This applies for a mac application, and not an iOS application.
My mac application can make screenshots of an iPhone.
The Mac must scan/colopick background color of these screenshots.
Thanks!
Sollution:
Down here the following code I used in an test environment, with 2 input fields so I can give an NSPoint.
The NSPoint is from bottom left, so I take image height - desired height.
This will get hex color code from image from x,y from topleft.
Code:
NSImage *image = [NSImage imageNamed:@"colorTest.png"];
NSLog(@"%f",image.size.width);
NSLog(@"%f",image.size.height);
NSPoint aPoint = NSMakePoint([posX.stringValue intValue] , (int)image.size.height - [posY.stringValue intValue]);
[image lockFocus];
NSColor *aColor = NSReadPixel(aPoint);
[image unlockFocus];
NSString* hexString = [NSString stringWithFormat:@"%02X%02X%02X",
(int) (aColor.redComponent * 0xFF), (int) (aColor.greenComponent * 0xFF),
(int) (aColor.blueComponent * 0xFF)];
Last edited: