Skip to content

Instantly share code, notes, and snippets.

@PadraigK
Last active August 29, 2015 14:01
Show Gist options
  • Save PadraigK/1362baef8b1912f78d09 to your computer and use it in GitHub Desktop.
Save PadraigK/1362baef8b1912f78d09 to your computer and use it in GitHub Desktop.
How do I pixels?
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
CGContextRef bmContext = CGBitmapContextCreate(NULL, width, height, 8, 4 * width, cs, (CGBitmapInfo) kCGImageAlphaNoneSkipLast);
CGContextDrawImage(bmContext, (CGRect){.origin.x = 0.0f, .origin.y = 0.0f, .size.width = width, .size.height = height}, imageRep);
CGColorSpaceRelease(cs);
RGBAPixel *pixels = (RGBAPixel*)CGBitmapContextGetData(bmContext);
// Outputting the first 10 pixels on different hardware (iPad Air, iPhone 5, Simulator) gives slightly differing pixel values.
// I am confuse.
@ls-bertrand-landry-hetu

It's most likely because these devices all have different color spaces/profiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment