diff options
Diffstat (limited to 'src/nsimage.m')
-rw-r--r-- | src/nsimage.m | 58 |
1 files changed, 6 insertions, 52 deletions
diff --git a/src/nsimage.m b/src/nsimage.m index fa81a41a519..dd2bb3b0d7b 100644 --- a/src/nsimage.m +++ b/src/nsimage.m @@ -254,31 +254,26 @@ ns_image_size_in_bytes (void *img) NSImageRep *imgRep; Lisp_Object found; EmacsImage *image; + NSString *filename; /* Search bitmap-file-path for the file, if appropriate. */ found = image_find_image_file (file); if (!STRINGP (found)) return nil; - found = ENCODE_FILE (found); + filename = [NSString stringWithLispString:found]; - image = [[EmacsImage alloc] initByReferencingFile: - [NSString stringWithLispString: found]]; + image = [[EmacsImage alloc] initByReferencingFile:filename]; image->bmRep = nil; -#ifdef NS_IMPL_COCOA - imgRep = [NSBitmapImageRep imageRepWithData:[image TIFFRepresentation]]; -#else - imgRep = [image bestRepresentationForDevice: nil]; -#endif - if (imgRep == nil) + if (![image isValid]) { [image release]; return nil; } + imgRep = [[image representations] firstObject]; [image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])]; - - [image setName: [NSString stringWithLispString: file]]; + [image setName:filename]; return image; } @@ -382,51 +377,10 @@ ns_image_size_in_bytes (void *img) } } - xbm_fg = fg; [self addRepresentation: bmRep]; return self; } -/* Set color for a bitmap image. */ -- (instancetype)setXBMColor: (NSColor *)color -{ - NSSize s = [self size]; - unsigned char *planes[5]; - EmacsCGFloat r, g, b, a; - NSColor *rgbColor; - - if (bmRep == nil || color == nil) - return self; - - if ([color colorSpace] != [NSColorSpace genericRGBColorSpace]) - rgbColor = [color colorUsingColorSpace:[NSColorSpace genericRGBColorSpace]]; - else - rgbColor = color; - - [rgbColor getRed: &r green: &g blue: &b alpha: &a]; - - [bmRep getBitmapDataPlanes: planes]; - - { - int i, len = s.width*s.height; - int rr = r * 0xff, gg = g * 0xff, bb = b * 0xff; - unsigned char fgr = (xbm_fg >> 16) & 0xff; - unsigned char fgg = (xbm_fg >> 8) & 0xff; - unsigned char fgb = xbm_fg & 0xff; - - for (i = 0; i < len; ++i) - if (planes[0][i] == fgr && planes[1][i] == fgg && planes[2][i] == fgb) - { - planes[0][i] = rr; - planes[1][i] = gg; - planes[2][i] = bb; - } - xbm_fg = ((rr << 16) & 0xff0000) + ((gg << 8) & 0xff00) + (bb & 0xff); - } - - return self; -} - - (instancetype)initForXPMWithDepth: (int)depth width: (int)width height: (int)height { |