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: QC comp to return CIImage instead of NSImage?



On Jan 25, 2007, at 10:48 AM, Dominik Westner wrote:

On

I have a QC composition, using just a VideoInput and a Sprite. The VideoInput's "Image" output is published. I run this from a Cocoa app, rendering it into a QCView. When I access the image using: id anImage=[qcView valueForOutputKey:@"Image"]; ...the object in anImage is an NSImage.

Is there any way to make it so I can get back a CIImage instead?
I just want to feed anImage into a CIFilter. I'm trying to avoid using:
[CIImage imageWithData:[anImage TIFFRepresentation]]


Roland

Well, actually a QC Composition should probably return an NSImage with a NSCIImageRep, so you could do something like this.

Here is a category on NSImage, which returns a CIImage, either from the NSCIImageRep if one exists or by creating a new CIImage from NSImage's bitmapRepresentation.

-(CIImage*) CIImage {
NSCIImageRep* rep = [self ciimageRepresentation];
if(rep) {
return [rep CIImage];
}
NSLog(@"No ciimage rep found -- creating one");
CIImage* result = [[[CIImage alloc] initWithBitmapImageRep:[self bitmapRepresentation]] autorelease];
[self addRepresentation:[NSCIImageRep imageRepWithCIImage:result]];
return result;
}


-(NSCIImageRep*) ciimageRepresentation {
	NSEnumerator *enumerator = [[self representations] objectEnumerator];
    NSImageRep *representation;
    while (representation = [enumerator nextObject]) {
        if ([representation isKindOfClass:[NSCIImageRep class]]) {
            return (NSCIImageRep *)representation;
        }
    }
	return nil;
}


Hi Dominik,

NSImage does not seem to have a -bitmapRepresentation method.
Also, representation is of class NSCGImageRep, not NSCIImageRep, and doesn't respond to method -CIImage.
Is there a missing category method?


Roland



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

This email sent to email@hidden
References: 
 >Re: QC comp to return CIImage instead of NSImage? (From: Dominik Westner <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.