/* Functions for image support on window system.
Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#define FRAME_X_VISUAL(f) FRAME_X_DISPLAY_INFO (f)->visual
#define x_defined_color mac_defined_color
#define DefaultDepthOfScreen(screen) (one_mac_display_info.n_planes)
-#define XDrawLine(display, w, gc, x1, y1, x2, y2) \
- mac_draw_line_to_pixmap(display, w, gc, x1, y1, x2, y2)
#endif /* MAC_OS */
struct frame *f;
struct image *img;
OSType type;
- FSSpec *fss;
+ const FSSpec *fss;
Handle dh;
{
- OSErr err;
+ ComponentResult err;
GraphicsImportComponent gi;
Rect rect;
int width, height;
XImagePtr ximg;
RGBColor bg_color;
- err = OpenADefaultComponent (GraphicsImporterComponentType,
- type, &gi);
+ err = OpenADefaultComponent (GraphicsImporterComponentType, type, &gi);
if (err != noErr)
{
image_error ("Cannot get importer component for `%s'", img->spec, Qnil);
expect_ident ("define");
expect (XBM_TK_IDENT);
- if (LA1 == XBM_TK_NUMBER);
+ if (LA1 == XBM_TK_NUMBER)
{
char *p = strrchr (buffer, '_');
p = p ? p + 1 : buffer;
/* XPM support functions for Mac OS where libxpm is not available.
Only XPM version 3 (without any extensions) is supported. */
-static int xpm_scan P_ ((unsigned char **, unsigned char *,
- unsigned char **, int *));
+static int xpm_scan P_ ((const unsigned char **, const unsigned char *,
+ const unsigned char **, int *));
static Lisp_Object xpm_make_color_table_v
- P_ ((void (**) (Lisp_Object, unsigned char *, int, Lisp_Object),
- Lisp_Object (**) (Lisp_Object, unsigned char *, int)));
-static void xpm_put_color_table_v P_ ((Lisp_Object, unsigned char *,
+ P_ ((void (**) (Lisp_Object, const unsigned char *, int, Lisp_Object),
+ Lisp_Object (**) (Lisp_Object, const unsigned char *, int)));
+static void xpm_put_color_table_v P_ ((Lisp_Object, const unsigned char *,
int, Lisp_Object));
static Lisp_Object xpm_get_color_table_v P_ ((Lisp_Object,
- unsigned char *, int));
+ const unsigned char *, int));
static Lisp_Object xpm_make_color_table_h
- P_ ((void (**) (Lisp_Object, unsigned char *, int, Lisp_Object),
- Lisp_Object (**) (Lisp_Object, unsigned char *, int)));
-static void xpm_put_color_table_h P_ ((Lisp_Object, unsigned char *,
+ P_ ((void (**) (Lisp_Object, const unsigned char *, int, Lisp_Object),
+ Lisp_Object (**) (Lisp_Object, const unsigned char *, int)));
+static void xpm_put_color_table_h P_ ((Lisp_Object, const unsigned char *,
int, Lisp_Object));
static Lisp_Object xpm_get_color_table_h P_ ((Lisp_Object,
- unsigned char *, int));
-static int xpm_str_to_color_key P_ ((char *));
+ const unsigned char *, int));
+static int xpm_str_to_color_key P_ ((const char *));
static int xpm_load_image P_ ((struct frame *, struct image *,
- unsigned char *, unsigned char *));
+ const unsigned char *, const unsigned char *));
/* Tokens returned from xpm_scan. */
static int
xpm_scan (s, end, beg, len)
- unsigned char **s, *end, **beg;
+ const unsigned char **s, *end, **beg;
int *len;
{
int c;
static Lisp_Object
xpm_make_color_table_v (put_func, get_func)
- void (**put_func) (Lisp_Object, unsigned char *, int, Lisp_Object);
- Lisp_Object (**get_func) (Lisp_Object, unsigned char *, int);
+ void (**put_func) (Lisp_Object, const unsigned char *, int, Lisp_Object);
+ Lisp_Object (**get_func) (Lisp_Object, const unsigned char *, int);
{
*put_func = xpm_put_color_table_v;
*get_func = xpm_get_color_table_v;
static void
xpm_put_color_table_v (color_table, chars_start, chars_len, color)
Lisp_Object color_table;
- unsigned char *chars_start;
+ const unsigned char *chars_start;
int chars_len;
Lisp_Object color;
{
static Lisp_Object
xpm_get_color_table_v (color_table, chars_start, chars_len)
Lisp_Object color_table;
- unsigned char *chars_start;
+ const unsigned char *chars_start;
int chars_len;
{
return XVECTOR (color_table)->contents[*chars_start];
static Lisp_Object
xpm_make_color_table_h (put_func, get_func)
- void (**put_func) (Lisp_Object, unsigned char *, int, Lisp_Object);
- Lisp_Object (**get_func) (Lisp_Object, unsigned char *, int);
+ void (**put_func) (Lisp_Object, const unsigned char *, int, Lisp_Object);
+ Lisp_Object (**get_func) (Lisp_Object, const unsigned char *, int);
{
*put_func = xpm_put_color_table_h;
*get_func = xpm_get_color_table_h;
static void
xpm_put_color_table_h (color_table, chars_start, chars_len, color)
Lisp_Object color_table;
- unsigned char *chars_start;
+ const unsigned char *chars_start;
int chars_len;
Lisp_Object color;
{
static Lisp_Object
xpm_get_color_table_h (color_table, chars_start, chars_len)
Lisp_Object color_table;
- unsigned char *chars_start;
+ const unsigned char *chars_start;
int chars_len;
{
struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
XPM_COLOR_KEY_C
};
-static char xpm_color_key_strings[][4] = {"s", "m", "g4", "g", "c"};
+static const char xpm_color_key_strings[][4] = {"s", "m", "g4", "g", "c"};
static int
xpm_str_to_color_key (s)
- char *s;
+ const char *s;
{
int i;
xpm_load_image (f, img, contents, end)
struct frame *f;
struct image *img;
- unsigned char *contents, *end;
+ const unsigned char *contents, *end;
{
- unsigned char *s = contents, *beg, *str;
+ const unsigned char *s = contents, *beg, *str;
unsigned char buffer[BUFSIZ];
int width, height, x, y;
int num_colors, chars_per_pixel;
int len, LA1;
- void (*put_color_table) (Lisp_Object, unsigned char *, int, Lisp_Object);
- Lisp_Object (*get_color_table) (Lisp_Object, unsigned char *, int);
+ void (*put_color_table) (Lisp_Object, const unsigned char *, int, Lisp_Object);
+ Lisp_Object (*get_color_table) (Lisp_Object, const unsigned char *, int);
Lisp_Object frame, color_symbols, color_table;
int best_key, have_mask = 0;
XImagePtr ximg = NULL, mask_img = NULL;
GC gc;
#ifdef MAC_OS
-#define XCreateGC_pixmap(dpy, pixmap) XCreateGC (dpy, NULL, 0, NULL)
#define MaskForeground(f) PIX_MASK_DRAW
#else
-#define XCreateGC_pixmap(dpy, pixmap) XCreateGC (dpy, pixmap, 0, NULL)
#define MaskForeground(f) WHITE_PIX_DEFAULT (f)
#endif
- gc = XCreateGC_pixmap (dpy, img->pixmap);
+ gc = XCreateGC (dpy, img->pixmap, 0, NULL);
XSetForeground (dpy, gc, BLACK_PIX_DEFAULT (f));
XDrawLine (dpy, img->pixmap, gc, 0, 0,
img->width - 1, img->height - 1);
if (img->mask)
{
- gc = XCreateGC_pixmap (dpy, img->mask);
+ gc = XCreateGC (dpy, img->mask, 0, NULL);
XSetForeground (dpy, gc, MaskForeground (f));
XDrawLine (dpy, img->mask, gc, 0, 0,
img->width - 1, img->height - 1);
}
else
{
+ if (raw_p && (p + 3 * height * width > end))
+ {
+ x_destroy_x_image (ximg);
+ image_error ("Invalid image size in image `%s'",
+ img->spec, Qnil);
+ goto error;
+ }
+
for (y = 0; y < height; ++y)
for (x = 0; x < width; ++x)
{
{
image_error ("Cannot open image file `%s'", file, Qnil);
UNGCPRO;
- fclose (fp);
return 0;
}