CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
CGContextRef renderingContext = CGBitmapContextCreate(NULL,
pageBounds.size.width,
pageBounds.size.height,
8,
pageBounds.size.width * 4,
colorSpace,
kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst);
CGContextSetFillColorSpace(renderingContext, colorSpace);
CGContextSetStrokeColorSpace(renderingContext, colorSpace);
CGColorSpaceRelease(colorSpace);
const CGFloat white[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
CGContextSetFillColor(renderingContext, white);
CGContextFillRect(renderingContext, pageBounds);
CGContextSaveGState(renderingContext);
// Do some rendering, occasionally calling CGContextSetFillColor or CGContextSetStrokeColor,
// but not changing the color space (unless it can happen implicitly?)
CGImageRef image = CGBitmapContextCreateImage(renderingContext);
CGImageDestinationRef pngDestination = CGImageDestinationCreateWithURL(
(__bridge CFURLRef)[NSURL fileURLWithPath:testOutputPDFPath],
kUTTypePNG,
1,
NULL);
CGImageDestinationAddImage(pngDestination, image, NULL);
CGImageDestinationFinalize(pngDestination);
CFRelease(pngDestination);
CGImageRelease(image);
Thanks!
Jamie. _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list (Quart...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/quartz-dev-garchive-50095%40googlegroups.com
This email sent to quartz-dev-g...@googlegroups.com
> I'd like to create PNG files using an sRGB color space. In my imagination, I'll be able to bytewise-compare files output by different runs of my program for testing purposes, to check the rendering doesn't change. This works mainly, but if I change monitors, the files start to be different even with no changes in the program. Looking at them visually, it looks like the color profiles are different (colors are slightly different shades).
If you're using a script to do that bytewise comparison, you could
have it run pngcrush first:
http://en.wikipedia.org/wiki/Pngcrush#Reducing_filesize_by_removing_color-correction_data
I'd be interested to hear an answer at the Quartz level if there is one, though.
H