nsimagerep

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 ...

How to avoid a NSCachedImageRep

I'm working with an NSImage which comes from a PDF. When I initially create the image, it has only one NSImageRep and that is NSPDFImageRep. This is good. I can work with it. I can find out how many pages it has, and go to a specified page, and draw it, etc. The problem is that as soon as I turn my back, it gets turned into a NSCachedIm...

NSImageRep confusion

I have an NSImage that came from a PDF, so it has one representation, of type NSPDFImageRep. I do an image setDataRetained:YES; to make sure that it remains a NSPDFImageRep. Later, I want to change the page, so I get the rep, and set the current page. This is fine. The problem is that when I draw the image, only the 1st page comes out. ...

Is there a best way to size an NSImage to a maximum filesize?

Here's what I've got so far: NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData: [file.image TIFFRepresentation]]; // Resize image to 200x200 CGFloat maxSize = 200.0; NSSize imageSize = imageRep.size; if (imageSize.height>maxSize || imageSize.width>maxSize) { // Find the aspect ratio CGFloat aspectRatio = imag...

How to compress jpeg image with Cocoa?

I have an jpeg image and I want to be able to incrementally compress it using Cocoa/Core Image/Core Graphics. For example, I have A.jpg (3MB), I compress A and get B.jpg (1MB), compress B and get C.jpg (400KB), and so on till the image can't be compressed anymore. I am trying to use NSBitmapImageRep representationUsingType:properties w...

NSImage and related APIs leaking memory

Hi Following is the code snippet that I have: // Make Auto release pool NSAutoreleasePool * autoReleasePool = [[NSAutoreleasePool alloc] init]; try { if (mCapture) { // Get the image reference NSImage* image = NULL; image = [mCapture getCurrentFrameImage]; // Get the TIFF data NSData *pDataTifData = [[NSData all...

NSImage size is wrong

Hi, I think i'm missing something really basic here. If I do this with a legal URL/path which I know exists: NSImage* img = [[NSImage alloc] initWithContentsOfFile:[[selectedItem url] path]]; NSLog(@"Image width: %d height: %d", [img size].width, [img size].height); then I get reported to the console that the width is -2080177216 and...