comparison src/glyphs-eimage.c @ 442:abe6d1db359e r21-2-36

Import from CVS: tag r21-2-36
author cvs
date Mon, 13 Aug 2007 11:35:02 +0200
parents 8de8e3f6228a
children 5fd7ba8b56e7
comparison
equal deleted inserted replaced
441:72a7cfa4a488 442:abe6d1db359e
54 #include "objects.h" 54 #include "objects.h"
55 55
56 #include "buffer.h" 56 #include "buffer.h"
57 #include "frame.h" 57 #include "frame.h"
58 #include "opaque.h" 58 #include "opaque.h"
59 #include "window.h"
59 60
60 #include "sysfile.h" 61 #include "sysfile.h"
61 62
62 #ifdef HAVE_PNG 63 #ifdef HAVE_PNG
63 #ifdef __cplusplus 64 #ifdef __cplusplus
116 { 117 {
117 file_or_data_must_be_present (instantiator); 118 file_or_data_must_be_present (instantiator);
118 } 119 }
119 120
120 static Lisp_Object 121 static Lisp_Object
121 jpeg_normalize (Lisp_Object inst, Lisp_Object console_type) 122 jpeg_normalize (Lisp_Object inst, Lisp_Object console_type,
123 Lisp_Object dest_mask)
122 { 124 {
123 return simple_image_type_normalize (inst, console_type, Qjpeg); 125 return simple_image_type_normalize (inst, console_type, Qjpeg);
124 } 126 }
125 127
126 static int 128 static int
370 372
371 /* Step 2: specify data source (eg, a file) */ 373 /* Step 2: specify data source (eg, a file) */
372 374
373 { 375 {
374 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 376 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
375 CONST Extbyte *bytes; 377 const Extbyte *bytes;
376 Extcount len; 378 Extcount len;
377 379
378 /* #### This is a definite problem under Mule due to the amount of 380 /* #### This is a definite problem under Mule due to the amount of
379 stack data it might allocate. Need to be able to convert and 381 stack data it might allocate. Need to be able to convert and
380 write out to a file. */ 382 write out to a file. */
478 } 480 }
479 } 481 }
480 482
481 /* Step 6.5: Create the pixmap and set up the image instance */ 483 /* Step 6.5: Create the pixmap and set up the image instance */
482 /* now instantiate */ 484 /* now instantiate */
483 MAYBE_DEVMETH (XDEVICE (ii->device), 485 MAYBE_DEVMETH (DOMAIN_XDEVICE (ii->domain),
484 init_image_instance_from_eimage, 486 init_image_instance_from_eimage,
485 (ii, cinfo.output_width, cinfo.output_height, 1, 487 (ii, cinfo.output_width, cinfo.output_height, 1,
486 unwind.eimage, dest_mask, 488 unwind.eimage, dest_mask,
487 instantiator, domain)); 489 instantiator, domain));
488 490
512 { 514 {
513 file_or_data_must_be_present (instantiator); 515 file_or_data_must_be_present (instantiator);
514 } 516 }
515 517
516 static Lisp_Object 518 static Lisp_Object
517 gif_normalize (Lisp_Object inst, Lisp_Object console_type) 519 gif_normalize (Lisp_Object inst, Lisp_Object console_type,
520 Lisp_Object dest_mask)
518 { 521 {
519 return simple_image_type_normalize (inst, console_type, Qgif); 522 return simple_image_type_normalize (inst, console_type, Qgif);
520 } 523 }
521 524
522 static int 525 static int
578 return 0; 581 return 0;
579 } 582 }
580 583
581 struct gif_error_struct 584 struct gif_error_struct
582 { 585 {
583 CONST char *err_str; /* return the error string */ 586 const char *err_str; /* return the error string */
584 jmp_buf setjmp_buffer; /* for return to caller */ 587 jmp_buf setjmp_buffer; /* for return to caller */
585 }; 588 };
586 589
587 static void 590 static void
588 gif_error_func(CONST char *err_str, VoidPtr error_ptr) 591 gif_error_func(const char *err_str, VoidPtr error_ptr)
589 { 592 {
590 struct gif_error_struct *error_data = (struct gif_error_struct*)error_ptr; 593 struct gif_error_struct *error_data = (struct gif_error_struct*)error_ptr;
591 594
592 /* return to setjmp point */ 595 /* return to setjmp point */
593 error_data->err_str = err_str; 596 error_data->err_str = err_str;
704 row += interlace ? InterlacedJumps[pass] : 1; 707 row += interlace ? InterlacedJumps[pass] : 1;
705 } 708 }
706 } 709 }
707 710
708 /* now instantiate */ 711 /* now instantiate */
709 MAYBE_DEVMETH (XDEVICE (ii->device), 712 MAYBE_DEVMETH (DOMAIN_XDEVICE (ii->domain),
710 init_image_instance_from_eimage, 713 init_image_instance_from_eimage,
711 (ii, width, height, unwind.giffile->ImageCount, unwind.eimage, dest_mask, 714 (ii, width, height, unwind.giffile->ImageCount, unwind.eimage, dest_mask,
712 instantiator, domain)); 715 instantiator, domain));
713 } 716 }
714 717
754 { 757 {
755 file_or_data_must_be_present (instantiator); 758 file_or_data_must_be_present (instantiator);
756 } 759 }
757 760
758 static Lisp_Object 761 static Lisp_Object
759 png_normalize (Lisp_Object inst, Lisp_Object console_type) 762 png_normalize (Lisp_Object inst, Lisp_Object console_type,
763 Lisp_Object dest_mask)
760 { 764 {
761 return simple_image_type_normalize (inst, console_type, Qpng); 765 return simple_image_type_normalize (inst, console_type, Qpng);
762 } 766 }
763 767
764 static int 768 static int
767 return IMAGE_COLOR_PIXMAP_MASK; 771 return IMAGE_COLOR_PIXMAP_MASK;
768 } 772 }
769 773
770 struct png_memory_storage 774 struct png_memory_storage
771 { 775 {
772 CONST Extbyte *bytes; /* The data */ 776 const Extbyte *bytes; /* The data */
773 Extcount len; /* How big is it? */ 777 Extcount len; /* How big is it? */
774 int index; /* Where are we? */ 778 int index; /* Where are we? */
775 }; 779 };
776 780
777 static void 781 static void
787 tbr->index = tbr->index + length; 791 tbr->index = tbr->index + length;
788 } 792 }
789 793
790 struct png_error_struct 794 struct png_error_struct
791 { 795 {
792 CONST char *err_str; 796 const char *err_str;
793 jmp_buf setjmp_buffer; /* for return to caller */ 797 jmp_buf setjmp_buffer; /* for return to caller */
794 }; 798 };
795 799
796 /* jh 98/03/12 - #### AARRRGH! libpng includes jmp_buf inside its own 800 /* jh 98/03/12 - #### AARRRGH! libpng includes jmp_buf inside its own
797 structure, and there are cases where the size can be different from 801 structure, and there are cases where the size can be different from
891 } 895 }
892 896
893 /* Initialize the IO layer and read in header information */ 897 /* Initialize the IO layer and read in header information */
894 { 898 {
895 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data); 899 Lisp_Object data = find_keyword_in_vector (instantiator, Q_data);
896 CONST Extbyte *bytes; 900 const Extbyte *bytes;
897 Extcount len; 901 Extcount len;
898 902
899 assert (!NILP (data)); 903 assert (!NILP (data));
900 904
901 /* #### This is a definite problem under Mule due to the amount of 905 /* #### This is a definite problem under Mule due to the amount of
947 951
948 c = XCOLOR_INSTANCE (bkgd); 952 c = XCOLOR_INSTANCE (bkgd);
949 rgblist = MAYBE_LISP_DEVMETH (XDEVICE (c->device), 953 rgblist = MAYBE_LISP_DEVMETH (XDEVICE (c->device),
950 color_instance_rgb_components, 954 color_instance_rgb_components,
951 (c)); 955 (c));
952 my_background.red = XINT (XCAR (rgblist)); 956 my_background.red = (unsigned short) XINT (XCAR (rgblist));
953 my_background.green = XINT (XCAR (XCDR (rgblist))); 957 my_background.green = (unsigned short) XINT (XCAR (XCDR (rgblist)));
954 my_background.blue = XINT (XCAR (XCDR (XCDR (rgblist)))); 958 my_background.blue = (unsigned short) XINT (XCAR (XCDR (XCDR (rgblist))));
955 } 959 }
956 960
957 if (png_get_bKGD (png_ptr, info_ptr, &image_background)) 961 if (png_get_bKGD (png_ptr, info_ptr, &image_background))
958 png_set_background (png_ptr, image_background, 962 png_set_background (png_ptr, image_background,
959 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); 963 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0);
1015 1019
1016 xfree (row_pointers); 1020 xfree (row_pointers);
1017 } 1021 }
1018 1022
1019 /* now instantiate */ 1023 /* now instantiate */
1020 MAYBE_DEVMETH (XDEVICE (ii->device), 1024 MAYBE_DEVMETH (DOMAIN_XDEVICE (ii->domain),
1021 init_image_instance_from_eimage, 1025 init_image_instance_from_eimage,
1022 (ii, width, height, 1, unwind.eimage, dest_mask, 1026 (ii, width, height, 1, unwind.eimage, dest_mask,
1023 instantiator, domain)); 1027 instantiator, domain));
1024 1028
1025 /* This will clean up everything else. */ 1029 /* This will clean up everything else. */
1040 { 1044 {
1041 file_or_data_must_be_present (instantiator); 1045 file_or_data_must_be_present (instantiator);
1042 } 1046 }
1043 1047
1044 static Lisp_Object 1048 static Lisp_Object
1045 tiff_normalize (Lisp_Object inst, Lisp_Object console_type) 1049 tiff_normalize (Lisp_Object inst, Lisp_Object console_type,
1050 Lisp_Object dest_mask)
1046 { 1051 {
1047 return simple_image_type_normalize (inst, console_type, Qtiff); 1052 return simple_image_type_normalize (inst, console_type, Qtiff);
1048 } 1053 }
1049 1054
1050 static int 1055 static int
1168 have any place to store error func data. This should be rectified 1173 have any place to store error func data. This should be rectified
1169 before XEmacs gets threads! */ 1174 before XEmacs gets threads! */
1170 static struct tiff_error_struct tiff_err_data; 1175 static struct tiff_error_struct tiff_err_data;
1171 1176
1172 static void 1177 static void
1173 tiff_error_func(CONST char *module, CONST char *fmt, ...) 1178 tiff_error_func(const char *module, const char *fmt, ...)
1174 { 1179 {
1175 va_list vargs; 1180 va_list vargs;
1176 1181
1177 va_start (vargs, fmt); 1182 va_start (vargs, fmt);
1178 #ifdef HAVE_VSNPRINTF 1183 #ifdef HAVE_VSNPRINTF
1185 /* return to setjmp point */ 1190 /* return to setjmp point */
1186 longjmp (tiff_err_data.setjmp_buffer, 1); 1191 longjmp (tiff_err_data.setjmp_buffer, 1);
1187 } 1192 }
1188 1193
1189 static void 1194 static void
1190 tiff_warning_func(CONST char *module, CONST char *fmt, ...) 1195 tiff_warning_func(const char *module, const char *fmt, ...)
1191 { 1196 {
1192 va_list vargs; 1197 va_list vargs;
1193 #ifdef HAVE_VSNPRINTF 1198 #ifdef HAVE_VSNPRINTF
1194 char warn_str[256]; 1199 char warn_str[256];
1195 #else 1200 #else
1252 Qbinary); 1257 Qbinary);
1253 mem_struct.bytes = bytes; 1258 mem_struct.bytes = bytes;
1254 mem_struct.len = len; 1259 mem_struct.len = len;
1255 mem_struct.index = 0; 1260 mem_struct.index = 0;
1256 1261
1257 unwind.tiff = TIFFClientOpen ("memfile", "r", &mem_struct, 1262 unwind.tiff = TIFFClientOpen ("memfile", "r", (thandle_t) &mem_struct,
1258 (TIFFReadWriteProc)tiff_memory_read, 1263 (TIFFReadWriteProc)tiff_memory_read,
1259 (TIFFReadWriteProc)tiff_memory_write, 1264 (TIFFReadWriteProc)tiff_memory_write,
1260 tiff_memory_seek, tiff_memory_close, tiff_memory_size, 1265 tiff_memory_seek, tiff_memory_close, tiff_memory_size,
1261 tiff_map_noop, tiff_unmap_noop); 1266 tiff_map_noop, tiff_unmap_noop);
1262 if (!unwind.tiff) 1267 if (!unwind.tiff)
1297 signal_image_error ("Unable to allocate memory for TIFFReadRGBA", instantiator); 1302 signal_image_error ("Unable to allocate memory for TIFFReadRGBA", instantiator);
1298 1303
1299 } 1304 }
1300 1305
1301 /* now instantiate */ 1306 /* now instantiate */
1302 MAYBE_DEVMETH (XDEVICE (ii->device), 1307 MAYBE_DEVMETH (DOMAIN_XDEVICE (ii->domain),
1303 init_image_instance_from_eimage, 1308 init_image_instance_from_eimage,
1304 (ii, width, height, 1, unwind.eimage, dest_mask, 1309 (ii, width, height, 1, unwind.eimage, dest_mask,
1305 instantiator, domain)); 1310 instantiator, domain));
1306 1311
1307 unbind_to (speccount, Qnil); 1312 unbind_to (speccount, Qnil);