Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSImage *picture = [[NSImage alloc] initWithContentsOfFile:@"bais2.tif"]; //file is located in resoureces folder.
- NSBitmapImageRep *imageRep = [[picture representations] objectAtIndex:0];
- NSColor* color = [imageRep colorAtX:10 y:10];
- NSLog(@"%f %f, %f", [color redComponent], [color blueComponent], [color greenComponent]);
- NSBitmapImageRep* imageRep = [[NSBitmapImageRep alloc] initWithData:[picture TIFFRepresentation]];
- NSImage *picture = [[NSImage alloc] initWithContentsOfFile:@"bais2.tif"];
- -------------------------------------------------------------------^^^^
- NSImage *picture= [NSImage imageNamed:@"bais2.tiff"];
- NSImage *picture = [[NSImage alloc] initWithContentsOfFile:@"bais2.tiff"];
- NSData *someNSData = [Image TIFFRepresentation];
- NSBitmapImageRep *someNSBitmapImageRepData = [[NSBitmapImageRep alloc] initWithData:someNSData];
- NSSize imageSizee = [someNSBitmapImageRepData size];
- CGFloat y = imageSize.height - 100.0;
- NSColor* color = [someNSBitmapImageRepData colorAtX:100.0 y:y];
- NSLog(@"color = %@",color);
- [yourImage lockFocus]; // yourImage is just your NSImage variable
- NSColor *pixelColor = NSReadPixel(NSMakePoint(1, 1)); // Or another point
- [yourImage unlockFocus];
Add Comment
Please, Sign In to add comment