Properly ask NSImage for an NSImageRef that is appropriately sized
authorMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 6 Aug 2009 14:12:54 +0000 (10:12 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Thu, 6 Aug 2009 14:14:36 +0000 (10:14 -0400)
for a screen resolution and let the NSImageView object worry about
scaling it.

Fixes the annoying problem of the gallery key images being really
really tiny.

iPhoto2Ansel/AnselExportController.m

index 591a819..cc9db65 100644 (file)
@@ -713,9 +713,17 @@ NSString * const TURAnselServerPasswordKey = @"password";
     currentGallery = [[anselController getGalleryByIndex:row] retain];
     [currentGallery setDelegate: self];
     
-    // TODO: Figure out why these don't always properly size.
+    // Obtain and properly size the image for screen
     NSImage *theImage = [[NSImage alloc] initWithContentsOfURL: [currentGallery galleryDefaultImageURL]];
+    NSSize imageSize;
+    imageSize.width = [[theImage bestRepresentationForDevice:nil] pixelsWide];
+    imageSize.height = [[theImage bestRepresentationForDevice:nil] pixelsHigh];    
+    [theImage setScalesWhenResized:YES];
+    [theImage setSize:imageSize];
+    
+    // Show it
     [defaultImageView setImage: theImage];
+
     [theImage release];
     [self canExport];
     [viewGallery setEnabled: YES];