X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/7ad8fe5e2876518a8f33b80050f98dab4ff78398..6340c70eb32758be2c3ca9059a3fb75bb9a79e72:/src/nsimage.m diff --git a/src/nsimage.m b/src/nsimage.m index cf974be6c4..9ef7ad37a0 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -1,5 +1,5 @@ /* Image support for the NeXT/Open/GNUstep and MacOSX window system. - Copyright (C) 1989, 1992, 1993, 1994, 2005, 2006, 2008 + Copyright (C) 1989, 1992, 1993, 1994, 2005, 2006, 2008, 2009 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -25,7 +25,10 @@ MacOSX/Aqua port by Christophe de Dinechin (descubes@earthlink.net) GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu) */ +/* This should be the first include, as it may set up #defines affecting + interpretation of even the system includes. */ #include "config.h" + #include "lisp.h" #include "dispextern.h" #include "nsterm.h" @@ -90,7 +93,7 @@ ns_load_image (struct frame *f, struct image *img, } else { - NSData *data = [NSData dataWithBytes: XSTRING (spec_data)->data + NSData *data = [NSData dataWithBytes: SDATA (spec_data) length: SBYTES (spec_data)]; eImg = [[EmacsImage alloc] initWithData: data]; [eImg setPixmapData]; @@ -160,6 +163,7 @@ static EmacsImage *ImageList = nil; + allocInitFromFile: (Lisp_Object)file { EmacsImage *image = ImageList; + NSImageRep *imgRep; Lisp_Object found; /* look for an existing image of the same name */ @@ -182,12 +186,18 @@ static EmacsImage *ImageList = nil; 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]; @@ -390,6 +400,12 @@ static EmacsImage *ImageList = nil; if ([bmRep numberOfPlanes] >= 3) [bmRep getBitmapDataPlanes: pixmapData]; + + /* The next two lines cause the DPI of the image to be ignored. + This seems to be the behavior users expect. */ + [self setScalesWhenResized: YES]; + [self setSize: NSMakeSize([bmRep pixelsWide], [bmRep pixelsHigh])]; + break; } } @@ -443,7 +459,8 @@ static EmacsImage *ImageList = nil; else if (onTiger) { [bmRep setColor: - [NSColor colorWithCalibratedRed: r green: g blue: b alpha: a] + [NSColor colorWithCalibratedRed: (r/255.0) green: (g/255.0) + blue: (b/255.0) alpha: (a/255.0)] atX: x y: y]; } }