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



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.

If you are grabbing from screen it seems pretty sensible to me. I use the code I sent you to get the colorspace of the underlying window + I setup a notification for screen changes as on multi display setups you will likelly have different colorspaces for each display....

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:
...


I don't see anything wrong with the code. You omited how the CIContext is created - have you looked in there? I guess you would go with: use the screen profile as the CIImage input CS and CIContext output CS. Use CoreImage's default working space (generic linear) for the compositing.

You might also try to change the screen profile of the machine where this is hapenning. Maybe it's the screen ICC profile that's confusing Core Image (I did have trouble once with a v4 ICC profile that wouldn't render correctly when used with CI), but I guess that's unlikelly.

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.

Looking at the numbers I'm pretty sure it's a gamma issue. Apply a gamma of 2.0 to the input and you'll get pretty close to the output.

Good hunting. 

I'm packing my stuff for a 10 day skying vacation right now - WOW - 10 long days without a computer nearby. I must be nuts.

Mark






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 = "">
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

 _______________________________________________
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>)
 >Re: Compositing issues with output from Quartz Patch (From: Neil Clayton <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.