diff src/nsimage.m @ 101318:06994fb0863f

* nsimage.m (EmacsImage+allocInitFromFile:): Set to ignore DPI. (Bug#1316)
author Adrian Robert <Adrian.B.Robert@gmail.com>
date Wed, 21 Jan 2009 17:28:05 +0000
parents e038c1a8307c
children 954e1944ccf2
line wrap: on
line diff
--- a/src/nsimage.m	Wed Jan 21 17:09:28 2009 +0000
+++ b/src/nsimage.m	Wed Jan 21 17:28:05 2009 +0000
@@ -163,6 +163,7 @@
 + allocInitFromFile: (Lisp_Object)file
 {
   EmacsImage *image = ImageList;
+  NSImageRep *imgRep;
   Lisp_Object found;
 
   /* look for an existing image of the same name */
@@ -185,12 +186,18 @@
   image = [[EmacsImage alloc] initByReferencingFile:
                      [NSString stringWithUTF8String: SDATA (found)]];
 
-  if ([image bestRepresentationForDevice: nil] == nil)
+  imgRep = [image bestRepresentationForDevice: nil];
+  if (imgRep == nil)
     {
       [image release];
       return nil;
     }
 
+  /* The next two lines cause the DPI of the image to be ignored.
+     This seems to be the behavior users expect. */
+  [image setScalesWhenResized: YES];
+  [image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])];
+
   [image setName: [NSString stringWithUTF8String: SDATA (file)]];
   [image reference];
   ImageList = [image imageListSetNext: ImageList];