Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: QC comp to return CIImage instead of NSImage?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: QC comp to return CIImage instead of NSImage?



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



Hi Roland,

well, sorry, you are right. I forgot to add the -bitmapRepresentation method in my last post (more or less stolen from one of Apple's examples):

-(NSBitmapImageRep*) bitmapRepresentation {
NSEnumerator *enumerator = [[self representations] objectEnumerator];
NSImageRep *representation;
while (representation = [enumerator nextObject]) {
if ([representation isKindOfClass:[NSBitmapImageRep class]]) {
return (NSBitmapImageRep *)representation;
}
}
NSLog(@"No bitmapImageRep found");
NSSize size = [self size];
[self lockFocus];
NSBitmapImageRep *bitmapImageRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:NSMakeRect(0, 0, size.width, size.height)];
[self unlockFocus];


return [bitmapImageRep autorelease];
}


Still QC seems to return NSCGImageRep, which is a private class. The header looks like this (courtesy of class-dump):

@interface NSCGImageRep : NSImageRep
{
struct CGImage *_cgImage;
unsigned int reserved1;
unsigned int reserved2;
unsigned int reserved3;
unsigned int reserved4;
}
+ (void)initialize;
- (id)init;
- (id)initWithCGImage:(struct CGImage *)fp8;
- (id)initWithFocusedViewRect:(struct _NSRect)fp8;
- (void)dealloc;
- (void)finalize;
- (id)copyWithZone:(struct _NSZone *)fp8;
- (id)initWithCoder:(id)fp8;
- (void)encodeWithCoder:(id)fp8;
- (struct CGImage *)CGImage;
- (BOOL)_isValid;
- (BOOL)draw;
- (BOOL)drawAtPoint:(struct _NSPoint)fp8;
- (BOOL)drawInRect:(struct _NSRect)fp8;
- (BOOL)_drawFromRect:(struct _NSRect)fp8 toRect:(struct _NSRect)fp24 operation:(int)fp40 alpha:(float)fp44 compositing:(BOOL)fp48 flipped: (BOOL)fp52 ignoreContext:(BOOL)fp56;


@end

You could get the CGImage from that and create a CIImage with its imageWithCGImage: method.
If this is more efficient and worth using unpublished API might be questionable...


Regards

Dominik
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden




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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.