/* Image support for the NeXT/Open/GNUstep and MacOSX window system.
- Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2015 Free Software
+ Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2016 Free Software
Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
void *
ns_image_from_file (Lisp_Object file)
{
- NSTRACE ("ns_image_from_bitmap_file");
+ NSTRACE ("ns_image_from_file");
return [EmacsImage allocInitFromFile: file];
}
}
+/* Create image from monochrome bitmap. If both FG and BG are 0
+ (black), set the background to white and make it transparent. */
- initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
fg: (unsigned long)fg bg: (unsigned long)bg
{
unsigned char *planes[5];
+ unsigned char bg_alpha = 0xff;
[self initWithSize: NSMakeSize (w, h)];
[bmRep getBitmapDataPlanes: planes];
if (fg == 0 && bg == 0)
- bg = 0xffffff;
+ {
+ bg = 0xffffff;
+ bg_alpha = 0;
+ }
{
/* pull bits out to set the (bytewise) alpha mask */
c = *s++;
for (k = 0; i < w && k < 8; ++k, ++i)
{
- *alpha++ = 0xff;
- if (c & 1)
+ if (c & 0x80)
{
*rr++ = fgr;
*gg++ = fgg;
*bb++ = fgb;
+ *alpha++ = 0xff;
}
else
{
*rr++ = bgr;
*gg++ = bgg;
*bb++ = bgb;
+ *alpha++ = bg_alpha;
}
idx++;
- c >>= 1;
+ c <<= 1;
}
}
}