views:

139

answers:

2

I'm working on an image viewer application (OSX) and currently it can load and view images, but I need to be able to view multi-page PDFs and TIFFs. I'll have next/previous page buttons, etc.

Now, with PDF, I expect to use an NSPDFImageRep. This will let me set the current page and draw the current page etc.

However, I don't see an NSTIFFImageRep, and the NSImageRep class doesn't seem to have any way of dealing with pages...

ETA (more specifics on my question): How do I work with a multi-page TIFF? In C, I used a CGImageSource which let me get the nth page. I don't see an equivalent for TIFFs in objective C.

thanks.

+1  A: 

I would expect that the easiest thing for you to do for a mixed PDF and TIFF viewer would be to make each non-PDF page a unique NSImageRep.

peterb
But how do I get the individual pages out of the TIFF file?If I can get the nth page in a multi-page TIFF, then I can do the rest...
Brian Postow
AH! Now I see. each page is a separate representation. that seems like an unfortunate use of the concept, but seems to work well enough.
Brian Postow
+1  A: 

I'm not positive, but IIRC if you initialize an NSImage with multi-page TIFF data, you will get one image rep per page. (Probably what peterb was alluding to.)

Edit: Check out +[NSBitmapImageRep imageRepsWithData:].

(via Apple Lists)

Wevah
I'll look into the ...withdata method. But if I just do an initWithFile on a TIFF file, I just get an NSImage of the 1st page...
Brian Postow
Try iterating through the array returned by -[NSImage representations]. An NSImage will only draw one of its representations if you ask it to draw directly!
Wevah