Mercurial > hg > xemacs-beta
comparison src/glyphs-x.c @ 272:c5d627a313b1 r21-0b34
Import from CVS: tag r21-0b34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:28:48 +0200 |
parents | b2472a1930f2 |
children | ca9a9ec9c1c1 |
comparison
equal
deleted
inserted
replaced
271:c7b7086b0a39 | 272:c5d627a313b1 |
---|---|
147 | 147 |
148 | 148 |
149 /************************************************************************/ | 149 /************************************************************************/ |
150 /* image instance methods */ | 150 /* image instance methods */ |
151 /************************************************************************/ | 151 /************************************************************************/ |
152 DOESNT_RETURN | 152 static DOESNT_RETURN |
153 signal_image_error(CONST char *reason, Lisp_Object frob) | 153 signal_image_error (CONST char *reason, Lisp_Object frob) |
154 { | 154 { |
155 signal_error (Qimage_conversion_error, list2 (build_translated_string (reason), frob)); | 155 signal_error (Qimage_conversion_error, |
156 } | 156 list2 (build_translated_string (reason), frob)); |
157 | 157 } |
158 DOESNT_RETURN | 158 |
159 signal_image_error_2 (CONST char *reason, | 159 static DOESNT_RETURN |
160 Lisp_Object frob0, Lisp_Object frob1) | 160 signal_image_error_2 (CONST char *reason, Lisp_Object frob0, Lisp_Object frob1) |
161 { | 161 { |
162 signal_error (Qimage_conversion_error, list3 (build_translated_string (reason), frob0, | 162 signal_error (Qimage_conversion_error, |
163 frob1)); | 163 list3 (build_translated_string (reason), frob0, frob1)); |
164 } | 164 } |
165 | 165 |
166 /************************************************************************/ | 166 /************************************************************************/ |
167 /* convert from a series of RGB triples to an XImage formated for the */ | 167 /* convert from a series of RGB triples to an XImage formated for the */ |
168 /* proper display */ | 168 /* proper display */ |
169 /************************************************************************/ | 169 /************************************************************************/ |
170 XImage * | 170 static XImage * |
171 convert_EImage_to_XImage(Lisp_Object device, int width, int height, unsigned char *pic, | 171 convert_EImage_to_XImage (Lisp_Object device, int width, int height, |
172 unsigned long **pixtbl, int *pixcount, int *npixels) | 172 unsigned char *pic, unsigned long **pixtbl, |
173 int *pixcount, int *npixels) | |
173 { | 174 { |
174 Display *dpy; | 175 Display *dpy; |
175 Colormap cmap; | 176 Colormap cmap; |
176 Visual *vis; | 177 Visual *vis; |
177 XImage *outimg; | 178 XImage *outimg; |
208 if (!outimg) return NULL; | 209 if (!outimg) return NULL; |
209 | 210 |
210 data = (unsigned char *) xmalloc (outimg->bytes_per_line * height); | 211 data = (unsigned char *) xmalloc (outimg->bytes_per_line * height); |
211 if (!data) | 212 if (!data) |
212 { | 213 { |
213 XDestroyImage(outimg); | 214 XDestroyImage (outimg); |
214 return NULL; | 215 return NULL; |
215 } | 216 } |
216 outimg->data = data; | 217 outimg->data = (char *) data; |
217 | 218 |
218 if (vis->class == PseudoColor) | 219 if (vis->class == PseudoColor) |
219 { | 220 { |
220 unsigned long pixarray[256]; | 221 unsigned long pixarray[256]; |
221 int n; | 222 int n; |
734 Lstream_close (istr); | 735 Lstream_close (istr); |
735 #ifdef FILE_CODING | 736 #ifdef FILE_CODING |
736 Lstream_close (costr); | 737 Lstream_close (costr); |
737 #endif | 738 #endif |
738 Lstream_close (ostr); | 739 Lstream_close (ostr); |
739 | 740 |
740 UNGCPRO; | 741 UNGCPRO; |
741 Lstream_delete (istr); | 742 Lstream_delete (istr); |
742 Lstream_delete (ostr); | 743 Lstream_delete (ostr); |
743 #ifdef FILE_CODING | 744 #ifdef FILE_CODING |
744 Lstream_delete (costr); | 745 Lstream_delete (costr); |
746 | 747 |
747 if (fubar) | 748 if (fubar) |
748 report_file_error ("Writing temp file", | 749 report_file_error ("Writing temp file", |
749 list1 (build_string (filename_out))); | 750 list1 (build_string (filename_out))); |
750 } | 751 } |
751 #endif | 752 #endif /* 0 */ |
752 | 753 |
753 | 754 |
754 /************************************************************************/ | 755 /************************************************************************/ |
755 /* cursor functions */ | 756 /* cursor functions */ |
756 /************************************************************************/ | 757 /************************************************************************/ |
919 static void | 920 static void |
920 check_valid_xbm_inline (Lisp_Object data) | 921 check_valid_xbm_inline (Lisp_Object data) |
921 { | 922 { |
922 Lisp_Object width, height, bits; | 923 Lisp_Object width, height, bits; |
923 | 924 |
924 CHECK_CONS (data); | 925 if (!CONSP (data) || |
925 if (!CONSP (XCDR (data)) || !CONSP (XCDR (XCDR (data))) || | 926 !CONSP (XCDR (data)) || |
927 !CONSP (XCDR (XCDR (data))) || | |
926 !NILP (XCDR (XCDR (XCDR (data))))) | 928 !NILP (XCDR (XCDR (XCDR (data))))) |
927 signal_simple_error ("Must be list of 3 elements", data); | 929 signal_simple_error ("Must be list of 3 elements", data); |
928 | 930 |
929 width = XCAR (data); | 931 width = XCAR (data); |
930 height = XCAR (XCDR (data)); | 932 height = XCAR (XCDR (data)); |
931 bits = XCAR (XCDR (XCDR (data))); | 933 bits = XCAR (XCDR (XCDR (data))); |
932 | 934 |
933 if (!INTP (width) || !INTP (height) || !STRINGP (bits)) | 935 CHECK_STRING (bits); |
934 signal_simple_error ("Must be (width height bits)", | 936 |
935 vector3 (width, height, bits)); | 937 if (!NATNUMP (width)) |
936 | 938 signal_simple_error ("Width must be a natural number", width); |
937 if (XINT (width) <= 0) | 939 |
938 signal_simple_error ("Width must be > 0", width); | 940 if (!NATNUMP (height)) |
939 | 941 signal_simple_error ("Height must be a natural number", height); |
940 if (XINT (height) <= 0) | 942 |
941 signal_simple_error ("Height must be > 0", height); | 943 if (((XINT (width) * XINT (height)) / 8) > XSTRING_CHAR_LENGTH (bits)) |
942 | 944 signal_simple_error ("data is too short for width and height", |
943 if (((unsigned) (XINT (width) * XINT (height)) / 8) | |
944 > string_char_length (XSTRING (bits))) | |
945 signal_simple_error ("data is too short for W and H", | |
946 vector3 (width, height, bits)); | 945 vector3 (width, height, bits)); |
947 } | 946 } |
948 | 947 |
949 /* Validate method for XBM's. */ | 948 /* Validate method for XBM's. */ |
950 | 949 |
1703 | 1702 |
1704 assert (!NILP (data)); | 1703 assert (!NILP (data)); |
1705 | 1704 |
1706 retry: | 1705 retry: |
1707 | 1706 |
1708 memset (&xpmattrs, 0, sizeof (xpmattrs)); /* want XpmInitAttributes() */ | 1707 xzero (xpmattrs); /* want XpmInitAttributes() */ |
1709 xpmattrs.valuemask = XpmReturnPixels; | 1708 xpmattrs.valuemask = XpmReturnPixels; |
1710 if (force_mono) | 1709 if (force_mono) |
1711 { | 1710 { |
1712 /* Without this, we get a 1-bit version of the color image, which | 1711 /* Without this, we get a 1-bit version of the color image, which |
1713 isn't quite right. With this, we get the mono image, which might | 1712 isn't quite right. With this, we get the mono image, which might |
2117 METHODDEF boolean | 2116 METHODDEF boolean |
2118 #endif | 2117 #endif |
2119 our_fill_input_buffer (j_decompress_ptr cinfo) | 2118 our_fill_input_buffer (j_decompress_ptr cinfo) |
2120 { | 2119 { |
2121 /* Insert a fake EOI marker */ | 2120 /* Insert a fake EOI marker */ |
2122 struct jpeg_source_mgr *src = (struct jpeg_source_mgr *) cinfo->src; | 2121 struct jpeg_source_mgr *src = cinfo->src; |
2123 static JOCTET buffer[2]; | 2122 static JOCTET buffer[2]; |
2124 | 2123 |
2125 buffer[0] = (JOCTET) 0xFF; | 2124 buffer[0] = (JOCTET) 0xFF; |
2126 buffer[1] = (JOCTET) JPEG_EOI; | 2125 buffer[1] = (JOCTET) JPEG_EOI; |
2127 | 2126 |
2161 #endif | 2160 #endif |
2162 our_term_source (j_decompress_ptr cinfo) | 2161 our_term_source (j_decompress_ptr cinfo) |
2163 { | 2162 { |
2164 } | 2163 } |
2165 | 2164 |
2166 typedef struct { | 2165 typedef struct |
2166 { | |
2167 struct jpeg_source_mgr pub; | 2167 struct jpeg_source_mgr pub; |
2168 } our_jpeg_source_mgr; | 2168 } our_jpeg_source_mgr; |
2169 | 2169 |
2170 static void | 2170 static void |
2171 jpeg_memory_src (j_decompress_ptr cinfo, JOCTET *data, unsigned int len) | 2171 jpeg_memory_src (j_decompress_ptr cinfo, JOCTET *data, unsigned int len) |
2172 { | 2172 { |
2173 struct jpeg_source_mgr *src = NULL; | 2173 struct jpeg_source_mgr *src; |
2174 | 2174 |
2175 if (cinfo->src == NULL) | 2175 if (cinfo->src == NULL) |
2176 { /* first time for this JPEG object? */ | 2176 { /* first time for this JPEG object? */ |
2177 cinfo->src = (struct jpeg_source_mgr *) | 2177 cinfo->src = (struct jpeg_source_mgr *) |
2178 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, | 2178 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, |
2254 vis = DEVICE_X_VISUAL (XDEVICE(device)); | 2254 vis = DEVICE_X_VISUAL (XDEVICE(device)); |
2255 | 2255 |
2256 /* Step -1: First record our unwind-protect, which will clean up after | 2256 /* Step -1: First record our unwind-protect, which will clean up after |
2257 any exit, normal or not */ | 2257 any exit, normal or not */ |
2258 | 2258 |
2259 memset (&unwind, 0, sizeof (unwind)); | 2259 xzero (unwind); |
2260 unwind.dpy = dpy; | 2260 unwind.dpy = dpy; |
2261 unwind.cmap = cmap; | 2261 unwind.cmap = cmap; |
2262 record_unwind_protect (jpeg_instantiate_unwind, make_opaque_ptr (&unwind)); | 2262 record_unwind_protect (jpeg_instantiate_unwind, make_opaque_ptr (&unwind)); |
2263 | 2263 |
2264 #ifdef USE_TEMP_FILES_FOR_JPEG_IMAGES | 2264 #ifdef USE_TEMP_FILES_FOR_JPEG_IMAGES |
2328 | 2328 |
2329 /* #### This is a definite problem under Mule due to the amount of | 2329 /* #### This is a definite problem under Mule due to the amount of |
2330 stack data it might allocate. Need to be able to convert and | 2330 stack data it might allocate. Need to be able to convert and |
2331 write out to a file. */ | 2331 write out to a file. */ |
2332 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len); | 2332 GET_STRING_BINARY_DATA_ALLOCA (data, bytes, len); |
2333 jpeg_memory_src (&cinfo, bytes, len); | 2333 jpeg_memory_src (&cinfo, (JOCTET *) bytes, len); |
2334 } | 2334 } |
2335 #endif | 2335 #endif |
2336 | 2336 |
2337 /* Step 3: read file parameters with jpeg_read_header() */ | 2337 /* Step 3: read file parameters with jpeg_read_header() */ |
2338 | 2338 |
2474 | 2474 |
2475 /* jpeg_read_scanlines expects an array of pointers to scanlines. | 2475 /* jpeg_read_scanlines expects an array of pointers to scanlines. |
2476 * Here the array is only one element long, but you could ask for | 2476 * Here the array is only one element long, but you could ask for |
2477 * more than one scanline at a time if that's more convenient. | 2477 * more than one scanline at a time if that's more convenient. |
2478 */ | 2478 */ |
2479 (void) jpeg_read_scanlines (&cinfo, row_buffer, 1); | 2479 jpeg_read_scanlines (&cinfo, row_buffer, 1); |
2480 | 2480 |
2481 for (i = 0; i < cinfo.output_width; i++) | 2481 for (i = 0; i < (int) cinfo.output_width; i++) |
2482 XPutPixel (unwind.ximage, i, scanline, | 2482 XPutPixel (unwind.ximage, i, scanline, |
2483 /* Let's make sure we avoid getting bit like | 2483 /* Let's make sure we avoid getting bit like |
2484 what happened for GIF's. It's probably the | 2484 what happened for GIF's. It's probably the |
2485 case that JSAMPLE's are unsigned chars as | 2485 case that JSAMPLE's are unsigned chars as |
2486 opposed to chars, but you never know. | 2486 opposed to chars, but you never know. |
2736 | 2736 |
2737 dpy = DEVICE_X_DISPLAY (XDEVICE (device)); | 2737 dpy = DEVICE_X_DISPLAY (XDEVICE (device)); |
2738 cmap = DEVICE_X_COLORMAP (XDEVICE(device)); | 2738 cmap = DEVICE_X_COLORMAP (XDEVICE(device)); |
2739 vis = DEVICE_X_VISUAL (XDEVICE(device)); | 2739 vis = DEVICE_X_VISUAL (XDEVICE(device)); |
2740 | 2740 |
2741 memset (&unwind, 0, sizeof (unwind)); | 2741 xzero (unwind); |
2742 unwind.dpy = dpy; | 2742 unwind.dpy = dpy; |
2743 unwind.cmap = cmap; | 2743 unwind.cmap = cmap; |
2744 record_unwind_protect (gif_instantiate_unwind, make_opaque_ptr (&unwind)); | 2744 record_unwind_protect (gif_instantiate_unwind, make_opaque_ptr (&unwind)); |
2745 | 2745 |
2746 /* 1. Now decode the data. */ | 2746 /* 1. Now decode the data. */ |
2801 for (i = 0; i < cmo->ColorCount; i++) | 2801 for (i = 0; i < cmo->ColorCount; i++) |
2802 { | 2802 { |
2803 int res; | 2803 int res; |
2804 XColor color; | 2804 XColor color; |
2805 | 2805 |
2806 color.red = cmo->Colors[i].Red << 8; | 2806 color.red = cmo->Colors[i].Red << 8; |
2807 color.green = cmo->Colors[i].Green << 8; | 2807 color.green = cmo->Colors[i].Green << 8; |
2808 color.blue = cmo->Colors[i].Blue << 8; | 2808 color.blue = cmo->Colors[i].Blue << 8; |
2809 color.flags = DoRed | DoGreen | DoBlue; | 2809 color.flags = DoRed | DoGreen | DoBlue; |
2810 | 2810 |
2811 res = allocate_nearest_color (dpy, cmap, vis, &color); | 2811 res = allocate_nearest_color (dpy, cmap, vis, &color); |
2812 if (res > 0 && res < 3) | 2812 if (res > 0 && res < 3) |
2813 { | 2813 { |
2981 } | 2981 } |
2982 | 2982 |
2983 #ifndef USE_TEMP_FILES_FOR_PNG_IMAGES | 2983 #ifndef USE_TEMP_FILES_FOR_PNG_IMAGES |
2984 struct png_memory_storage | 2984 struct png_memory_storage |
2985 { | 2985 { |
2986 Extbyte *bytes; /* The data */ | 2986 CONST Extbyte *bytes; /* The data */ |
2987 Extcount len; /* How big is it? */ | 2987 Extcount len; /* How big is it? */ |
2988 int index; /* Where are we? */ | 2988 int index; /* Where are we? */ |
2989 }; | 2989 }; |
2990 | 2990 |
2991 static void | 2991 static void |
3015 passed in the png_ptr to them. This is an ugly hack and must | 3015 passed in the png_ptr to them. This is an ugly hack and must |
3016 go away when the lisp engine is threaded! */ | 3016 go away when the lisp engine is threaded! */ |
3017 static struct png_error_struct png_err_stct; | 3017 static struct png_error_struct png_err_stct; |
3018 | 3018 |
3019 static void | 3019 static void |
3020 png_error_func(png_structp png_ptr, png_const_charp message) | 3020 png_error_func (png_structp png_ptr, png_const_charp msg) |
3021 { | 3021 { |
3022 png_err_stct.err_str = message; | 3022 png_err_stct.err_str = msg; |
3023 longjmp (png_err_stct.setjmp_buffer, 1); | 3023 longjmp (png_err_stct.setjmp_buffer, 1); |
3024 } | 3024 } |
3025 | 3025 |
3026 static void | 3026 static void |
3027 png_warning_func(png_structp png_ptr, png_const_charp message) | 3027 png_warning_func (png_structp png_ptr, png_const_charp msg) |
3028 { | 3028 { |
3029 warn_when_safe (Qpng, Qinfo, "%s", message); | 3029 warn_when_safe (Qpng, Qinfo, "%s", msg); |
3030 } | 3030 } |
3031 | 3031 |
3032 struct png_unwind_data | 3032 struct png_unwind_data |
3033 { | 3033 { |
3034 Display *dpy; | 3034 Display *dpy; |
3114 { | 3114 { |
3115 png_destroy_read_struct (&png_ptr, (png_infopp)NULL, (png_infopp)NULL); | 3115 png_destroy_read_struct (&png_ptr, (png_infopp)NULL, (png_infopp)NULL); |
3116 signal_image_error ("Error obtaining memory for png_read", instantiator); | 3116 signal_image_error ("Error obtaining memory for png_read", instantiator); |
3117 } | 3117 } |
3118 | 3118 |
3119 memset (&unwind, 0, sizeof (unwind)); | 3119 xzero (unwind); |
3120 unwind.png_ptr = png_ptr; | 3120 unwind.png_ptr = png_ptr; |
3121 unwind.info_ptr = info_ptr; | 3121 unwind.info_ptr = info_ptr; |
3122 unwind.dpy = dpy; | 3122 unwind.dpy = dpy; |
3123 unwind.cmap = cmap; | 3123 unwind.cmap = cmap; |
3124 | 3124 |
3143 } | 3143 } |
3144 | 3144 |
3145 /* Initialize the IO layer and read in header information */ | 3145 /* Initialize the IO layer and read in header information */ |
3146 { | 3146 { |
3147 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); | 3147 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); |
3148 Extbyte *bytes; | 3148 CONST Extbyte *bytes; |
3149 Extcount len; | 3149 Extcount len; |
3150 struct png_memory_storage tbr; /* Data to be read */ | 3150 struct png_memory_storage tbr; /* Data to be read */ |
3151 | 3151 |
3152 assert (!NILP (data)); | 3152 assert (!NILP (data)); |
3153 | 3153 |
3217 { | 3217 { |
3218 if (!(info_ptr->valid & PNG_INFO_PLTE)) | 3218 if (!(info_ptr->valid & PNG_INFO_PLTE)) |
3219 { | 3219 { |
3220 for (y = 0; y < 216; y++) | 3220 for (y = 0; y < 216; y++) |
3221 { | 3221 { |
3222 static_color_cube[y].red = (y % 6) * 255.0 / 5; | 3222 static_color_cube[y].red = (png_byte) ((y % 6) * 255.0 / 5); |
3223 static_color_cube[y].green = ((y / 6) % 6) * 255.0 / 5; | 3223 static_color_cube[y].green = (png_byte) (((y / 6) % 6) * 255.0 / 5); |
3224 static_color_cube[y].blue = (y / 36) * 255.0 / 5; | 3224 static_color_cube[y].blue = (png_byte) ((y / 36) * 255.0 / 5); |
3225 } | 3225 } |
3226 png_set_dither (png_ptr, static_color_cube, 216, 216, NULL, 1); | 3226 png_set_dither (png_ptr, static_color_cube, 216, 216, NULL, 1); |
3227 } | 3227 } |
3228 else | 3228 else |
3229 { | 3229 { |
3240 { | 3240 { |
3241 unwind.npixels = 0; | 3241 unwind.npixels = 0; |
3242 for (y = 0; y < info_ptr->num_palette; y++) | 3242 for (y = 0; y < info_ptr->num_palette; y++) |
3243 { | 3243 { |
3244 int res; | 3244 int res; |
3245 color.red = info_ptr->palette[y].red << 8; | 3245 color.red = info_ptr->palette[y].red << 8; |
3246 color.green = info_ptr->palette[y].green << 8; | 3246 color.green = info_ptr->palette[y].green << 8; |
3247 color.blue = info_ptr->palette[y].blue << 8; | 3247 color.blue = info_ptr->palette[y].blue << 8; |
3248 color.flags = DoRed | DoGreen | DoBlue; | 3248 color.flags = DoRed | DoGreen | DoBlue; |
3249 res = allocate_nearest_color (dpy, cmap, vis, &color); | 3249 res = allocate_nearest_color (dpy, cmap, vis, &color); |
3250 if (res > 0 && res < 3) | 3250 if (res > 0 && res < 3) |
3251 { | 3251 { |
3252 DO_REALLOC(unwind.pixels, unwind.pixcount, unwind.npixels+1, unsigned long); | 3252 DO_REALLOC(unwind.pixels, unwind.pixcount, unwind.npixels+1, unsigned long); |
3259 { | 3259 { |
3260 unwind.npixels = 0; | 3260 unwind.npixels = 0; |
3261 for (y = 0; y < 216; y++) | 3261 for (y = 0; y < 216; y++) |
3262 { | 3262 { |
3263 int res; | 3263 int res; |
3264 color.red = static_color_cube[y].red << 8; | 3264 color.red = static_color_cube[y].red << 8; |
3265 color.green = static_color_cube[y].green << 8; | 3265 color.green = static_color_cube[y].green << 8; |
3266 color.blue = static_color_cube[y].blue << 8; | 3266 color.blue = static_color_cube[y].blue << 8; |
3267 color.flags = DoRed|DoGreen|DoBlue; | 3267 color.flags = DoRed|DoGreen|DoBlue; |
3268 res = allocate_nearest_color (dpy, cmap, vis, &color); | 3268 res = allocate_nearest_color (dpy, cmap, vis, &color); |
3269 if (res > 0 && res < 3) | 3269 if (res > 0 && res < 3) |
3270 { | 3270 { |
3271 unwind.pixels[unwind.npixels] = color.pixel; | 3271 unwind.pixels[unwind.npixels] = color.pixel; |
3383 /* if the png specifies a background chunk, go ahead and | 3383 /* if the png specifies a background chunk, go ahead and |
3384 use it */ | 3384 use it */ |
3385 png_color_16 my_background, *image_background; | 3385 png_color_16 my_background, *image_background; |
3386 | 3386 |
3387 /* ### how do I get the background of the current frame? */ | 3387 /* ### how do I get the background of the current frame? */ |
3388 my_background.red = 0x7fff; | 3388 my_background.red = 0x7fff; |
3389 my_background.green = 0x7fff; | 3389 my_background.green = 0x7fff; |
3390 my_background.blue = 0x7fff; | 3390 my_background.blue = 0x7fff; |
3391 | 3391 |
3392 if (png_get_bKGD (png_ptr, info_ptr, &image_background)) | 3392 if (png_get_bKGD (png_ptr, info_ptr, &image_background)) |
3393 png_set_background (png_ptr, image_background, | 3393 png_set_background (png_ptr, image_background, |
3394 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); | 3394 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); |
3395 else | 3395 else |
3524 tiff_memory_read(thandle_t data, tdata_t buf, tsize_t size) | 3524 tiff_memory_read(thandle_t data, tdata_t buf, tsize_t size) |
3525 { | 3525 { |
3526 tiff_memory_storage *mem = (tiff_memory_storage*)data; | 3526 tiff_memory_storage *mem = (tiff_memory_storage*)data; |
3527 | 3527 |
3528 if (size > (mem->len - mem->index)) | 3528 if (size > (mem->len - mem->index)) |
3529 return -1; | 3529 return (size_t) -1; |
3530 memcpy(buf, mem->bytes + mem->index, size); | 3530 memcpy(buf, mem->bytes + mem->index, size); |
3531 mem->index = mem->index + size; | 3531 mem->index = mem->index + size; |
3532 return size; | 3532 return size; |
3533 } | 3533 } |
3534 | 3534 |
3662 signal_simple_error ("Not an X device", device); | 3662 signal_simple_error ("Not an X device", device); |
3663 | 3663 |
3664 dpy = DEVICE_X_DISPLAY (XDEVICE (device)); | 3664 dpy = DEVICE_X_DISPLAY (XDEVICE (device)); |
3665 cmap = DEVICE_X_COLORMAP (XDEVICE(device)); | 3665 cmap = DEVICE_X_COLORMAP (XDEVICE(device)); |
3666 | 3666 |
3667 memset (&unwind, 0, sizeof (unwind)); | 3667 xzero (unwind); |
3668 unwind.dpy = dpy; | 3668 unwind.dpy = dpy; |
3669 unwind.cmap = cmap; | 3669 unwind.cmap = cmap; |
3670 record_unwind_protect (tiff_instantiate_unwind, make_opaque_ptr (&unwind)); | 3670 record_unwind_protect (tiff_instantiate_unwind, make_opaque_ptr (&unwind)); |
3671 | 3671 |
3672 /* set up error facilities */ | 3672 /* set up error facilities */ |
3706 if (!unwind.tiff) | 3706 if (!unwind.tiff) |
3707 signal_image_error ("Insufficent memory to instantiate TIFF image", instantiator); | 3707 signal_image_error ("Insufficent memory to instantiate TIFF image", instantiator); |
3708 | 3708 |
3709 TIFFGetField (unwind.tiff, TIFFTAG_IMAGEWIDTH, &width); | 3709 TIFFGetField (unwind.tiff, TIFFTAG_IMAGEWIDTH, &width); |
3710 TIFFGetField (unwind.tiff, TIFFTAG_IMAGELENGTH, &height); | 3710 TIFFGetField (unwind.tiff, TIFFTAG_IMAGELENGTH, &height); |
3711 unwind.eimage = xmalloc (width * height * 3); | 3711 unwind.eimage = (unsigned char *) xmalloc (width * height * 3); |
3712 | 3712 |
3713 /* ### This is little more than proof-of-concept/function testing. | 3713 /* ### This is little more than proof-of-concept/function testing. |
3714 It needs to be reimplimented via scanline reads for both memory | 3714 It needs to be reimplimented via scanline reads for both memory |
3715 compactness. */ | 3715 compactness. */ |
3716 raster = (uint32*) _TIFFmalloc (width * height * sizeof (uint32)); | 3716 raster = (uint32*) _TIFFmalloc (width * height * sizeof (uint32)); |
4305 /************************************************************************/ | 4305 /************************************************************************/ |
4306 /* subwindows */ | 4306 /* subwindows */ |
4307 /************************************************************************/ | 4307 /************************************************************************/ |
4308 | 4308 |
4309 Lisp_Object Qsubwindowp; | 4309 Lisp_Object Qsubwindowp; |
4310 static Lisp_Object mark_subwindow (Lisp_Object, void (*) (Lisp_Object)); | |
4311 static void print_subwindow (Lisp_Object, Lisp_Object, int); | |
4312 static void finalize_subwindow (void *, int); | |
4313 static int subwindow_equal (Lisp_Object o1, Lisp_Object o2, int depth); | |
4314 static unsigned long subwindow_hash (Lisp_Object obj, int depth); | |
4315 DEFINE_LRECORD_IMPLEMENTATION ("subwindow", subwindow, | |
4316 mark_subwindow, print_subwindow, | |
4317 finalize_subwindow, subwindow_equal, | |
4318 subwindow_hash, struct Lisp_Subwindow); | |
4319 | 4310 |
4320 static Lisp_Object | 4311 static Lisp_Object |
4321 mark_subwindow (Lisp_Object obj, void (*markobj) (Lisp_Object)) | 4312 mark_subwindow (Lisp_Object obj, void (*markobj) (Lisp_Object)) |
4322 { | 4313 { |
4323 struct Lisp_Subwindow *sw = XSUBWINDOW (obj); | 4314 struct Lisp_Subwindow *sw = XSUBWINDOW (obj); |
4384 subwindow_hash (Lisp_Object obj, int depth) | 4375 subwindow_hash (Lisp_Object obj, int depth) |
4385 { | 4376 { |
4386 return XSUBWINDOW (obj)->subwindow; | 4377 return XSUBWINDOW (obj)->subwindow; |
4387 } | 4378 } |
4388 | 4379 |
4380 DEFINE_LRECORD_IMPLEMENTATION ("subwindow", subwindow, | |
4381 mark_subwindow, print_subwindow, | |
4382 finalize_subwindow, subwindow_equal, | |
4383 subwindow_hash, struct Lisp_Subwindow); | |
4384 | |
4389 /* #### PROBLEM: The display routines assume that the glyph is only | 4385 /* #### PROBLEM: The display routines assume that the glyph is only |
4390 being displayed in one buffer. If it is in two different buffers | 4386 being displayed in one buffer. If it is in two different buffers |
4391 which are both being displayed simultaneously you will lose big time. | 4387 which are both being displayed simultaneously you will lose big time. |
4392 This can be dealt with in the new redisplay. */ | 4388 This can be dealt with in the new redisplay. */ |
4393 | 4389 |
4489 XChangeProperty (dpy, sw->subwindow, property_atom, XA_STRING, 8, | 4485 XChangeProperty (dpy, sw->subwindow, property_atom, XA_STRING, 8, |
4490 PropModeReplace, | 4486 PropModeReplace, |
4491 XSTRING_DATA (data), | 4487 XSTRING_DATA (data), |
4492 XSTRING_LENGTH (data)); | 4488 XSTRING_LENGTH (data)); |
4493 | 4489 |
4494 return (property); | 4490 return property; |
4495 } | 4491 } |
4496 | 4492 |
4497 DEFUN ("subwindowp", Fsubwindowp, 1, 1, 0, /* | 4493 DEFUN ("subwindowp", Fsubwindowp, 1, 1, 0, /* |
4498 Return non-nil if OBJECT is a subwindow. | 4494 Return non-nil if OBJECT is a subwindow. |
4499 Subwindows are not currently implemented. | 4495 Subwindows are not currently implemented. |
4500 */ | 4496 */ |
4501 (object)) | 4497 (object)) |
4502 { | 4498 { |
4503 return (SUBWINDOWP (object) ? Qt : Qnil); | 4499 return SUBWINDOWP (object) ? Qt : Qnil; |
4504 } | 4500 } |
4505 | 4501 |
4506 DEFUN ("subwindow-width", Fsubwindow_width, 1, 1, 0, /* | 4502 DEFUN ("subwindow-width", Fsubwindow_width, 1, 1, 0, /* |
4507 Width of SUBWINDOW. | 4503 Width of SUBWINDOW. |
4508 Subwindows are not currently implemented. | 4504 Subwindows are not currently implemented. |
4509 */ | 4505 */ |
4510 (subwindow)) | 4506 (subwindow)) |
4511 { | 4507 { |
4512 CHECK_SUBWINDOW (subwindow); | 4508 CHECK_SUBWINDOW (subwindow); |
4513 return (make_int (XSUBWINDOW (subwindow)->width)); | 4509 return make_int (XSUBWINDOW (subwindow)->width); |
4514 } | 4510 } |
4515 | 4511 |
4516 DEFUN ("subwindow-height", Fsubwindow_height, 1, 1, 0, /* | 4512 DEFUN ("subwindow-height", Fsubwindow_height, 1, 1, 0, /* |
4517 Height of SUBWINDOW. | 4513 Height of SUBWINDOW. |
4518 Subwindows are not currently implemented. | 4514 Subwindows are not currently implemented. |
4519 */ | 4515 */ |
4520 (subwindow)) | 4516 (subwindow)) |
4521 { | 4517 { |
4522 CHECK_SUBWINDOW (subwindow); | 4518 CHECK_SUBWINDOW (subwindow); |
4523 return (make_int (XSUBWINDOW (subwindow)->height)); | 4519 return make_int (XSUBWINDOW (subwindow)->height); |
4524 } | 4520 } |
4525 | 4521 |
4526 DEFUN ("subwindow-xid", Fsubwindow_xid, 1, 1, 0, /* | 4522 DEFUN ("subwindow-xid", Fsubwindow_xid, 1, 1, 0, /* |
4527 Return the xid of SUBWINDOW as a number. | 4523 Return the xid of SUBWINDOW as a number. |
4528 Subwindows are not currently implemented. | 4524 Subwindows are not currently implemented. |
4529 */ | 4525 */ |
4530 (subwindow)) | 4526 (subwindow)) |
4531 { | 4527 { |
4532 CHECK_SUBWINDOW (subwindow); | 4528 CHECK_SUBWINDOW (subwindow); |
4533 return (make_int (XSUBWINDOW (subwindow)->subwindow)); | 4529 return make_int (XSUBWINDOW (subwindow)->subwindow); |
4534 } | 4530 } |
4535 | 4531 |
4536 DEFUN ("resize-subwindow", Fresize_subwindow, 1, 3, 0, /* | 4532 DEFUN ("resize-subwindow", Fresize_subwindow, 1, 3, 0, /* |
4537 Resize SUBWINDOW to WIDTH x HEIGHT. | 4533 Resize SUBWINDOW to WIDTH x HEIGHT. |
4538 If a value is nil that parameter is not changed. | 4534 If a value is nil that parameter is not changed. |