Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compositing issues with output from Quartz Patch




Thanks Mark,

Profile wise, under Leopard It's set to a custom profile called "30 Calibrated", and "Color LCD Calibrated" under Tiger.
I was only using the profile set by the user since it seemed like a sensible thing to do, not necessarily because I know that it's a sensible thing to do. Under Leopard at least, it made things work - so I figured it was OK. I could of course be completely wrong.



My render chain goes like this:

1) Get ARGB from OpenGL, into a CVPixelBuffer
2) Grab a section 128x128 from that pixel buffer, and render into a temporary CIImage context
3) Render the patch, into a pbuffer, then create a CIImage from that.
4) Render the result of the patch back into the original CVPixelBuffer, replacing the original 128x128 rect that we sampled in (2)



All of the bitmap contexts and CVPixelBuffers used here are created using the color space returned from the function I originally pasted (so either the platform color space, or the generic if that doesn't load).



I spent some time outputting images at various stages of the pipeline. It seems that the image is being modified before it hits QCRenderer.


When I perform step (1) above, that's fine. Colors are correct.
If output the contents of the CVPixelBuffer after step 2, the colors are modified on Tiger (but not in Leopard).


Step 2 is this:

CIImage *image = [CIImage imageWithCVImageBuffer:[frame pixelBuffer]];
CGContextRef context = [compositor createBitmapContext:[renderer clickImageBuffer] cSpace:[SWBColorSpaces currentColorSpace]];
[compositor drawImageAtPointIn:context image:image position:CGPointZero rect:wantedRect];
[compositor releaseBitmapContext:context buffer:[renderer clickImageBuffer]];

unsigned char *buffers[] = { CGBitmapContextGetData(context) };
[renderer saveToDisk:buffers width:128 height:128];


I've tried creating the context with kCGColorSpaceGenericRGB and DeviceRGB - they do differ a little, but still the colors are wrong.

The original RGB values of the blue of a highlited row in a table is 56,117,215. After grabbing and turning into a CIImage via a CGBitmapContext, that turns into 116,179,239. Once it's composited back onto the original frame it has become 170,217,250.

I feel I'm missing something quite basic here... can't for the life of me spot it at the moment.
Any tips/suggestions that I might try?


--
Regards,
Neil Clayton,  http://shinywhitebox.com







On 15/03/2008, at 12:08 AM, Mark wrote:

You can try the following code to get the name of the ICC profile, just in case that's the problem (taken from some Apple sample):

- (NSString *)CMProfileDescription
{
	CMProfileRef prof = [self colorSyncProfile];
	if (!prof) return nil;
	
   Str255			name;
   ScriptCode		code;
	CFStringRef		str = nil;
   CMError			err;


// for v4 profiles, try to get the best localized name from the 'desc'/'mluc' tag
err = CMCopyProfileLocalizedString(prof, cmProfileDescriptionTag, 0,0, &str);
// if that didn't work...
if (err != noErr)
{
// for Apple's localized v2 profiles, try to get the best localized name from the 'dscm'/'mluc' tag
err = CMCopyProfileLocalizedString(prof, cmProfileDescriptionMLTag, 0,0, &str);
// if that didn't work...
if (err != noErr)
{
// for normal v2 profiles, get the name from the 'desc'/'desc' tag
err = CMGetScriptProfileDescription( prof, name, &code);
// convert it to a CFString
if (err == noErr)
{
str = CFStringCreateWithPascalString(0, name, code);
}
}
}
return [(NSString *)str autorelease];
}




To get the colorspace of a window I've been using the following code:

@implementation NSWindow ( NSWindowExtensions )

- (CGDirectDisplayID)windowDisplayID
{
return (CGDirectDisplayID)[[[[self screen] deviceDescription] objectForKey:@"NSScreenNumber"] longValue];
}


- (NSColorSpace *)windowColorSpace
{
CMProfileRef profile = NULL;
NSColorSpace *colorspace = nil;

if (CMGetProfileByAVID((CMDisplayIDType)[self windowDisplayID], &profile) == noErr)
{
colorspace = [[NSColorSpace alloc] initWithColorSyncProfile:profile];
CMCloseProfile(profile);
}


	return [colorspace autorelease];
}

@end

HTH
mark


On 14.03.2008, at 09:00, Neil Clayton wrote:
Hello Everbodeeee,

I've a simple patch, with a single image input, an affine transform (that flips the image) to a clear and billboard (width 2).
Effectively, because the source image is upside down (coming from OpenGL) this patch just flips it. The idea is that I pass in a 128x128 image around the mouse cursor, and then replace what I took with the content of the patch - therefore being able to animate (and generally mess with) the content under the mouse at any time.


On Leopard it renders just fine.

However on Tiger it's as if the gamma has been bumped up hugely. It's not quite white, but close. You can still make out the fact that the image contains the right stuff, it's just the colors are way off.

When compositing, I'm setting up my color spaces using :

+ (CGColorSpaceRef) currentColorSpace {
	CMProfileRef current = nil;
	CGColorSpaceRef cSpace = nil;
	CMError error = CMGetSystemProfile(&current);
	if(error == 0) {
		cSpace = CGColorSpaceCreateWithPlatformColorSpace(current);
	} else {
		[self log:@"Can't get system profile color space, %lf", error];
	}
	
	if(cSpace == 0) {
		cSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
	}
	return cSpace;
}

The idea being that I want to use the color space setup by the user.
All of my bitmap context creation uses the same color space (well, they all end up calling this method to get one - they don't share the same ref).


I've got a whole lot more I could write about creation of pixel buffers (and their color spaces), etc - but I don't want to cloud this first question with too much stuff.


Is there anything I should look for here - that's Tiger specific?

I'm at a bit of a loss! Primarily because it works so well on Leopard.

--
Regards,
Neil Clayton,  http://shinywhitebox.com







_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden

This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Quartz-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/quartz-dev/email@hidden

This email sent to email@hidden
References: 
 >Compositing issues with output from Quartz Patch (From: Neil Clayton <email@hidden>)
 >Re: Compositing issues with output from Quartz Patch (From: Mark <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.