Guest User

Untitled

a guest
Jan 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. NSImage *picture = [[NSImage alloc] initWithContentsOfFile:@"bais2.tif"]; //file is located in resoureces folder.
  2. NSBitmapImageRep *imageRep = [[picture representations] objectAtIndex:0];
  3.  
  4. NSColor* color = [imageRep colorAtX:10 y:10];
  5. NSLog(@"%f %f, %f", [color redComponent], [color blueComponent], [color greenComponent]);
  6.  
  7. NSBitmapImageRep* imageRep = [[NSBitmapImageRep alloc] initWithData:[picture TIFFRepresentation]];
  8.  
  9. NSImage *picture = [[NSImage alloc] initWithContentsOfFile:@"bais2.tif"];
  10. -------------------------------------------------------------------^^^^
  11.  
  12. NSImage *picture= [NSImage imageNamed:@"bais2.tiff"];
  13.  
  14. NSImage *picture = [[NSImage alloc] initWithContentsOfFile:@"bais2.tiff"];
  15.  
  16. NSData *someNSData = [Image TIFFRepresentation];
  17. NSBitmapImageRep *someNSBitmapImageRepData = [[NSBitmapImageRep alloc] initWithData:someNSData];
  18. NSSize imageSizee = [someNSBitmapImageRepData size];
  19.  
  20. CGFloat y = imageSize.height - 100.0;
  21. NSColor* color = [someNSBitmapImageRepData colorAtX:100.0 y:y];
  22.  
  23. NSLog(@"color = %@",color);
  24.  
  25. [yourImage lockFocus]; // yourImage is just your NSImage variable
  26. NSColor *pixelColor = NSReadPixel(NSMakePoint(1, 1)); // Or another point
  27. [yourImage unlockFocus];
Add Comment
Please, Sign In to add comment