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;
}