3

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.

Brian Postow
  • 11,709
  • 17
  • 81
  • 125

2 Answers2

1

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
  • 1,360
  • 9
  • 14
  • 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 Aug 19 '09 at 21:39
  • 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 Aug 20 '09 at 18:24
1

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
  • 28,182
  • 7
  • 83
  • 72
  • 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 Aug 19 '09 at 22:11
  • 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 Aug 19 '09 at 22:31