]> code.delx.au - gnu-emacs/blobdiff - src/nsimage.m
Use INTERNAL_FIELD for windows.
[gnu-emacs] / src / nsimage.m
index 13761ba5f71a4fca204b1d1e6420417b759d459a..1479294948bf707d5a28a29f9f7bbc9787698a2e 100644 (file)
@@ -1,5 +1,5 @@
 /* Image support for the NeXT/Open/GNUstep and MacOSX window system.
-   Copyright (C) 1989, 1992, 1993, 1994, 2005, 2006, 2008, 2009, 2010
+   Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2012
      Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -83,19 +83,21 @@ int
 ns_load_image (struct frame *f, struct image *img,
                Lisp_Object spec_file, Lisp_Object spec_data)
 {
-  EmacsImage *eImg;
+  EmacsImage *eImg = nil;
   NSSize size;
 
   NSTRACE (ns_load_image);
 
-  if (NILP (spec_data))
+  if (STRINGP (spec_file))
     {
       eImg = [EmacsImage allocInitFromFile: spec_file];
     }
-  else
+  else if (STRINGP (spec_data))
     {
-      NSData *data = [NSData dataWithBytes: SDATA (spec_data)
-                                    length: SBYTES (spec_data)];
+      NSData *data;
+
+      data = [NSData dataWithBytes: SSDATA (spec_data)
+                           length: SBYTES (spec_data)];
       eImg = [[EmacsImage alloc] initWithData: data];
       [eImg setPixmapData];
     }
@@ -169,7 +171,7 @@ static EmacsImage *ImageList = nil;
 
   /* look for an existing image of the same name */
   while (image != nil &&
-         [[image name] compare: [NSString stringWithUTF8String: SDATA (file)]]
+         [[image name] compare: [NSString stringWithUTF8String: SSDATA (file)]]
              != NSOrderedSame)
     image = [image imageListNext];
 
@@ -185,9 +187,13 @@ static EmacsImage *ImageList = nil;
     return nil;
 
   image = [[EmacsImage alloc] initByReferencingFile:
-                     [NSString stringWithUTF8String: SDATA (found)]];
+                     [NSString stringWithUTF8String: SSDATA (found)]];
 
+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+  imgRep = [NSBitmapImageRep imageRepWithData:[image TIFFRepresentation]];
+#else
   imgRep = [image bestRepresentationForDevice: nil];
+#endif
   if (imgRep == nil)
     {
       [image release];
@@ -199,7 +205,7 @@ static EmacsImage *ImageList = nil;
   [image setScalesWhenResized: YES];
   [image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])];
 
-  [image setName: [NSString stringWithUTF8String: SDATA (file)]];
+  [image setName: [NSString stringWithUTF8String: SSDATA (file)]];
   [image reference];
   ImageList = [image imageListSetNext: ImageList];
 
@@ -328,13 +334,12 @@ static EmacsImage *ImageList = nil;
 - setXBMColor: (NSColor *)color
 {
   NSSize s = [self size];
-  int len = (int) s.width * s.height;
   unsigned char *planes[5];
   CGFloat r, g, b, a;
   NSColor *rgbColor;
 
   if (bmRep == nil || color == nil)
-    return;
+    return self;
 
   if ([color colorSpaceName] != NSCalibratedRGBColorSpace)
     rgbColor = [color colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
@@ -359,6 +364,8 @@ static EmacsImage *ImageList = nil;
           planes[2][i] = bb;
         }
   }
+
+  return self;
 }
 
 
@@ -392,7 +399,7 @@ static EmacsImage *ImageList = nil;
   NSImageRep *rep;
 
   reps = [[self representations] objectEnumerator];
-  while (rep = (NSImageRep *) [reps nextObject])
+  while ((rep = (NSImageRep *) [reps nextObject]))
     {
       if ([rep respondsToSelector: @selector (getBitmapDataPlanes:)])
         {
@@ -495,4 +502,3 @@ static EmacsImage *ImageList = nil;
 
 @end
 
-// arch-tag: 6b310280-6892-4e5e-8f34-41c4d384874f