objective-cnsimagensimagerep

NSBitmapImageRep and multi-page TIFFs


I've got a program that can open TIFF documents and display them. I'm using setFlipped:YES.

If I'm just dealing with single page image files, I can do

[image setFlipped: YES];

and that, in addition to the view being flipped, seems to draw the image correctly.

However, for some reason, setting the flipped of the image doesn't seem to affect the flippedness of the individual representations.

This is relevant because the multiple images of a multi-page TIFF seem to appear as different "representations" of the same image. So, if I just draw the IMAGE, it's flipped, but if I draw a specific representation, it isn't flipped. I also can't seem to figure out how to chose which representation is the default one that gets drawn when you draw the NSImage.

thanks.


Solution

  • I believe that the answer is that Yes, different pages are separate representations, and the correct way to deal with them is to turn them into images with:

    NSImage *im = [[NSImage alloc] initWithData:[representation TIFFRepresentation]];
    [im setFlipped:YES];