/* Image support for the NeXT/Open/GNUstep and MacOSX window system.
- Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2014 Free Software
+ Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2015 Free Software
Foundation, Inc.
This file is part of GNU Emacs.
#include "nsterm.h"
#include "frame.h"
-extern Lisp_Object QCfile, QCdata;
-
/* call tracing */
#if 0
int image_trace_num = 0;
@implementation EmacsImage
-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 */
- while (image != nil &&
- [[image name] compare: [NSString stringWithUTF8String: SSDATA (file)]]
- != NSOrderedSame)
- image = [image imageListNext];
-
- if (image != nil)
- {
- [image reference];
- return image;
- }
+ EmacsImage *image;
/* Search bitmap-file-path for the file, if appropriate. */
found = x_find_image_file (file);
image = [[EmacsImage alloc] initByReferencingFile:
[NSString stringWithUTF8String: SSDATA (found)]];
-#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+ image->bmRep = nil;
+#ifdef NS_IMPL_COCOA
imgRep = [NSBitmapImageRep imageRepWithData:[image TIFFRepresentation]];
#else
imgRep = [image bestRepresentationForDevice: nil];
[image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])];
[image setName: [NSString stringWithUTF8String: SSDATA (file)]];
- [image reference];
- ImageList = [image imageListSetNext: ImageList];
return image;
}
-- reference
-{
- refCount++;
- return self;
-}
-
-
-- imageListSetNext: (id)arg
-{
- imageListNext = arg;
- return self;
-}
-
-
-- imageListNext
-{
- return imageListNext;
-}
-
-
- (void)dealloc
{
- id list = ImageList;
-
- if (refCount > 1)
- {
- refCount--;
- return;
- }
-
[stippleMask release];
-
- if (list == self)
- ImageList = imageListNext;
- else
- {
- while (list != nil && [list imageListNext] != self)
- list = [list imageListNext];
- [list imageListSetNext: imageListNext];
- }
-
+ [bmRep release];
[super dealloc];
}
if (s >= bits + length)
{
[bmRep release];
+ bmRep = nil;
return nil;
}
#define hexchar(x) ('0' <= (x) && (x) <= '9' ? (x) - '0' : (x) - 'a' + 10)
{
if ([rep respondsToSelector: @selector (getBitmapDataPlanes:)])
{
- bmRep = (NSBitmapImageRep *) rep;
+ NSBitmapImageRep *bmr = (NSBitmapImageRep *) rep;
- if ([bmRep numberOfPlanes] >= 3)
- [bmRep getBitmapDataPlanes: pixmapData];
+ if ([bmr numberOfPlanes] >= 3)
+ [bmr 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])];
+ [self setSize: NSMakeSize([bmr pixelsWide], [bmr pixelsHigh])];
break;
}