Re: CGContextSetRGBFillColor() off by one?
Re: CGContextSetRGBFillColor() off by one?
- Subject: Re: CGContextSetRGBFillColor() off by one?
- From: "Ken Ferry" <email@hidden>
- Date: Fri, 30 May 2008 12:38:12 -0700
> Well... I'm not sure that's true any more is it? I mean, don't all the
> DeviceXXX colour spaces get mapped to the new "Generic" ones as of 10.4?
I don't believe so, and that isn't what I see in testing.
I filed a bug for this yesterday. My understanding, which may be
flawed, is that using a 'device' colorspace is a pledge that you know
that your color components are already with respect to the colorspace
of the destination, so require no further color correction.
The generic colorspaces are device-independent.
int main (int argc, const char * argv[]) {
uint32_t pixel = 0;
CGColorSpaceRef genericColorSpace =
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
CGColorSpaceRef deviceColorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef ctx = CGBitmapContextCreate(&pixel, 1, 1, 8, 4,
genericColorSpace,
kCGImageAlphaPremultipliedLast|kCGBitmapByteOrder32Host);
CGFloat components[4] = {(CGFloat)0xaa/0xff, (CGFloat)0xbb/0xff,
(CGFloat)0xcc/0xff, 1.0};
pixel = 0;
CGContextSetFillColorSpace(ctx, deviceColorSpace);
CGContextSetFillColor(ctx, components);
CGContextFillRect(ctx, CGRectMake(0, 0, 1, 1));
uint32_t deviceColorPixel = pixel;
pixel = 0;
CGContextSetFillColorSpace(ctx, genericColorSpace);
CGContextSetFillColor(ctx, components);
CGContextFillRect(ctx, CGRectMake(0, 0, 1, 1));
uint32_t genericColorPixel = pixel;
printf("Expected same result for device:%#X and generic:%#X
fills\n", deviceColorPixel, genericColorPixel);
CFRelease(genericColorSpace);
CFRelease(deviceColorSpace);
CFRelease(ctx);
return 0;
}
On Fri, May 30, 2008 at 9:52 AM, Alastair Houghton
<email@hidden> wrote:
> On 30 May 2008, at 02:21, Ken Ferry wrote:
>
>> Well, if you use CGContextSetRGBFillColor as you said, then that sets
>> a device RGB colorspace up as the fill colorspace, and device
>> colorspaces don't do color matching. Device means 'untagged'. Which
>> is to say, I don't know, sounds strange.
>
> Well... I'm not sure that's true any more is it? I mean, don't all the
> DeviceXXX colour spaces get mapped to the new "Generic" ones as of 10.4? So
> it may well be doing some sort of colour correction.
>
> Kind regards,
>
> Alastair.
>
> --
> http://alastairs-place.net
>
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden