On Aug 10, 2010, at 6:02 PM, Nick Zitzmann wrote:

> 
> On Aug 10, 2010, at 3:45 PM, Brian Postow wrote:
> 
>> Is there something obvious that I'm missing?
> 
> Yes. If you can require Leopard or later, then just create an 
> NSBitmapImageRep using -initWithCGImage:, then create the NSImage with the 
> size of the CGImage and add that NSBitmapImageRep to the NSImage. If not, 
> then create a new image with the size of the CGImage, lock focus on the 
> image, draw the CGImage using CGContextDrawImage(), and unlock focus.
> 
> Nick Zitzmann
> <http://www.chronosnet.com/>
> 
> 


Excellent! Now is there an easier way to get the CGImage out of the PDFPage 
than:

        PDFPage * pg = [doc pageAtIndex: pageNum -1];

        NSData* imgData = [pg dataRepresentation];
        NSImage* img = [[NSImage alloc] initWithData:imgData ];

        imgData = [img TIFFRepresentation]; 
                
        CGImageSourceRef imageSource = 
                CGImageSourceCreateWithData((CFDataRef)imgData,  NULL);
        NSDictionary * options = [NSDictionary dictionaryWithObject: 
                                                                                
        (id)kCFBooleanTrue  
                                                                                
forKey: (id) kCGImageSourceShouldCache];
        CGImageRef imgRef = CGImageSourceCreateImageAtIndex(imageSource, 0, 
options);


? About 1/2 of the time I seem to be crashing in the dataRepresentation call 
for some reason... 


Brian Postow
Senior Software Engineer
Acordex Imaging Systems

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to