Mercurial > emacs
comparison src/w32fns.c @ 54137:ea218f839fc1
(slurp_file, xbm_scan, xbm_load_image)
(xbm_read_bitmap_data): Use unsigned char for image data.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Tue, 24 Feb 2004 09:00:24 +0000 |
parents | 0093eae529e8 |
children | 18d3533d8911 |
comparison
equal
deleted
inserted
replaced
54136:8025b7d4aa49 | 54137:ea218f839fc1 |
---|---|
8241 /*********************************************************************** | 8241 /*********************************************************************** |
8242 File Handling | 8242 File Handling |
8243 ***********************************************************************/ | 8243 ***********************************************************************/ |
8244 | 8244 |
8245 static Lisp_Object x_find_image_file P_ ((Lisp_Object)); | 8245 static Lisp_Object x_find_image_file P_ ((Lisp_Object)); |
8246 static char *slurp_file P_ ((char *, int *)); | 8246 static unsigned char *slurp_file P_ ((char *, int *)); |
8247 | 8247 |
8248 | 8248 |
8249 /* Find image file FILE. Look in data-directory, then | 8249 /* Find image file FILE. Look in data-directory, then |
8250 x-bitmap-file-path. Value is the full name of the file found, or | 8250 x-bitmap-file-path. Value is the full name of the file found, or |
8251 nil if not found. */ | 8251 nil if not found. */ |
8277 | 8277 |
8278 /* Read FILE into memory. Value is a pointer to a buffer allocated | 8278 /* Read FILE into memory. Value is a pointer to a buffer allocated |
8279 with xmalloc holding FILE's contents. Value is null if an error | 8279 with xmalloc holding FILE's contents. Value is null if an error |
8280 occurred. *SIZE is set to the size of the file. */ | 8280 occurred. *SIZE is set to the size of the file. */ |
8281 | 8281 |
8282 static char * | 8282 static unsigned char * |
8283 slurp_file (file, size) | 8283 slurp_file (file, size) |
8284 char *file; | 8284 char *file; |
8285 int *size; | 8285 int *size; |
8286 { | 8286 { |
8287 FILE *fp = NULL; | 8287 FILE *fp = NULL; |
8288 char *buf = NULL; | 8288 unsigned char *buf = NULL; |
8289 struct stat st; | 8289 struct stat st; |
8290 | 8290 |
8291 if (stat (file, &st) == 0 | 8291 if (stat (file, &st) == 0 |
8292 && (fp = fopen (file, "rb")) != NULL | 8292 && (fp = fopen (file, "rb")) != NULL |
8293 && (buf = (char *) xmalloc (st.st_size), | 8293 && (buf = (char *) xmalloc (st.st_size), |
8314 | 8314 |
8315 /*********************************************************************** | 8315 /*********************************************************************** |
8316 XBM images | 8316 XBM images |
8317 ***********************************************************************/ | 8317 ***********************************************************************/ |
8318 | 8318 |
8319 static int xbm_scan P_ ((char **, char *, char *, int *)); | 8319 static int xbm_scan P_ ((unsigned char **, unsigned char *, char *, int *)); |
8320 static int xbm_load P_ ((struct frame *f, struct image *img)); | 8320 static int xbm_load P_ ((struct frame *f, struct image *img)); |
8321 static int xbm_load_image P_ ((struct frame *f, struct image *img, | 8321 static int xbm_load_image P_ ((struct frame *f, struct image *img, |
8322 char *, char *)); | 8322 unsigned char *, unsigned char *)); |
8323 static int xbm_image_p P_ ((Lisp_Object object)); | 8323 static int xbm_image_p P_ ((Lisp_Object object)); |
8324 static int xbm_read_bitmap_data P_ ((char *, char *, int *, int *, | 8324 static int xbm_read_bitmap_data P_ ((unsigned char *, unsigned char *, |
8325 unsigned char **)); | 8325 int *, int *, unsigned char **)); |
8326 static int xbm_file_p P_ ((Lisp_Object)); | 8326 static int xbm_file_p P_ ((Lisp_Object)); |
8327 | 8327 |
8328 | 8328 |
8329 /* Indices of image specification fields in xbm_format, below. */ | 8329 /* Indices of image specification fields in xbm_format, below. */ |
8330 | 8330 |
8509 identifier, store the lexeme of the identifier in SVAL. If | 8509 identifier, store the lexeme of the identifier in SVAL. If |
8510 scanning a number, store its value in *IVAL. */ | 8510 scanning a number, store its value in *IVAL. */ |
8511 | 8511 |
8512 static int | 8512 static int |
8513 xbm_scan (s, end, sval, ival) | 8513 xbm_scan (s, end, sval, ival) |
8514 char **s, *end; | 8514 unsigned char **s, *end; |
8515 char *sval; | 8515 char *sval; |
8516 int *ival; | 8516 int *ival; |
8517 { | 8517 { |
8518 int c; | 8518 unsigned int c; |
8519 | 8519 |
8520 loop: | 8520 loop: |
8521 | 8521 |
8522 /* Skip white space. */ | 8522 /* Skip white space. */ |
8523 while (*s < end && (c = *(*s)++, isspace (c))) | 8523 while (*s < end && (c = *(*s)++, isspace (c))) |
8643 Value is non-zero if successful. DATA null means just test if | 8643 Value is non-zero if successful. DATA null means just test if |
8644 CONTENTS looks like an in-memory XBM file. */ | 8644 CONTENTS looks like an in-memory XBM file. */ |
8645 | 8645 |
8646 static int | 8646 static int |
8647 xbm_read_bitmap_data (contents, end, width, height, data) | 8647 xbm_read_bitmap_data (contents, end, width, height, data) |
8648 char *contents, *end; | 8648 unsigned char *contents, *end; |
8649 int *width, *height; | 8649 int *width, *height; |
8650 unsigned char **data; | 8650 unsigned char **data; |
8651 { | 8651 { |
8652 char *s = contents; | 8652 unsigned char *s = contents; |
8653 char buffer[BUFSIZ]; | 8653 char buffer[BUFSIZ]; |
8654 int padding_p = 0; | 8654 int padding_p = 0; |
8655 int v10 = 0; | 8655 int v10 = 0; |
8656 int bytes_per_line, i, nbytes; | 8656 int bytes_per_line, i, nbytes; |
8657 unsigned char *p; | 8657 unsigned char *p; |
8825 | 8825 |
8826 static int | 8826 static int |
8827 xbm_load_image (f, img, contents, end) | 8827 xbm_load_image (f, img, contents, end) |
8828 struct frame *f; | 8828 struct frame *f; |
8829 struct image *img; | 8829 struct image *img; |
8830 char *contents, *end; | 8830 unsigned char *contents, *end; |
8831 { | 8831 { |
8832 int rc; | 8832 int rc; |
8833 unsigned char *data; | 8833 unsigned char *data; |
8834 int success_p = 0; | 8834 int success_p = 0; |
8835 | 8835 |
8913 /* If IMG->spec specifies a file name, create a non-file spec from it. */ | 8913 /* If IMG->spec specifies a file name, create a non-file spec from it. */ |
8914 file_name = image_spec_value (img->spec, QCfile, NULL); | 8914 file_name = image_spec_value (img->spec, QCfile, NULL); |
8915 if (STRINGP (file_name)) | 8915 if (STRINGP (file_name)) |
8916 { | 8916 { |
8917 Lisp_Object file; | 8917 Lisp_Object file; |
8918 char *contents; | 8918 unsigned char *contents; |
8919 int size; | 8919 int size; |
8920 struct gcpro gcpro1; | 8920 struct gcpro gcpro1; |
8921 | 8921 |
8922 file = x_find_image_file (file_name); | 8922 file = x_find_image_file (file_name); |
8923 GCPRO1 (file); | 8923 GCPRO1 (file); |