Mercurial > emacs
comparison src/w32fns.c @ 49448:26edfad422c5
(XPutPixel): Handle monochrome images; used for masks.
[HAVE_PNG]: Sync with xfns.c version.
(png_load): Adjust colors for Windows. Use Windows
bitmaps. Disable color table lookups.
(DEF_IMGLIB_FN, LOAD_IMGLIB_FN): New macros.
(init_png_functions): New function.
(png_read_from_memory, png_load): Call png library functions
through pointers determined at runtime.
(QCloader, QCbounding_box, QCpt_width, QCpt_height): Declare.
(init_external_image_libraries): New function.
(init_xfns): Call it.
author | Jason Rumney <jasonr@gnu.org> |
---|---|
date | Sat, 25 Jan 2003 20:45:29 +0000 |
parents | 8185febf8361 |
children | a6825c5c7ce7 |
comparison
equal
deleted
inserted
replaced
49447:d5ef8b62f209 | 49448:26edfad422c5 |
---|---|
55 #include <dlgs.h> | 55 #include <dlgs.h> |
56 #define FILE_NAME_TEXT_FIELD edt1 | 56 #define FILE_NAME_TEXT_FIELD edt1 |
57 | 57 |
58 void syms_of_w32fns (); | 58 void syms_of_w32fns (); |
59 void globals_of_w32fns (); | 59 void globals_of_w32fns (); |
60 static void init_external_image_libraries (); | |
60 | 61 |
61 extern void free_frame_menubar (); | 62 extern void free_frame_menubar (); |
62 extern void x_compute_fringe_widths P_ ((struct frame *, int)); | 63 extern void x_compute_fringe_widths P_ ((struct frame *, int)); |
63 extern double atof (); | 64 extern double atof (); |
64 extern int w32_console_toggle_lock_key P_ ((int, Lisp_Object)); | 65 extern int w32_console_toggle_lock_key P_ ((int, Lisp_Object)); |
9334 | 9335 |
9335 /*********************************************************************** | 9336 /*********************************************************************** |
9336 W32 support code | 9337 W32 support code |
9337 ***********************************************************************/ | 9338 ***********************************************************************/ |
9338 | 9339 |
9340 /* Macro for defining functions that will be loaded from image DLLs. */ | |
9341 #define DEF_IMGLIB_FN(func) FARPROC fn_##func | |
9342 | |
9343 /* Macro for loading those image functions from the library. */ | |
9344 #define LOAD_IMGLIB_FN(lib,func) { \ | |
9345 fn_##func = (void *) GetProcAddress (lib, #func); \ | |
9346 if (!fn_##func) return 0; \ | |
9347 } | |
9348 | |
9339 static int x_create_x_image_and_pixmap P_ ((struct frame *, int, int, int, | 9349 static int x_create_x_image_and_pixmap P_ ((struct frame *, int, int, int, |
9340 XImage **, Pixmap *)); | 9350 XImage **, Pixmap *)); |
9341 static void x_put_x_image P_ ((struct frame *, XImage *, Pixmap, int, int)); | 9351 static void x_put_x_image P_ ((struct frame *, XImage *, Pixmap, int, int)); |
9342 | 9352 |
9343 | 9353 |
10841 *pixel = *pixel | (1 << x % 8); | 10851 *pixel = *pixel | (1 << x % 8); |
10842 else | 10852 else |
10843 *pixel = *pixel & ~(1 << x % 8); | 10853 *pixel = *pixel & ~(1 << x % 8); |
10844 } | 10854 } |
10845 else | 10855 else |
10846 image_error ("XPutPixel: palette image not supported.", NULL, Qnil); | 10856 image_error ("XPutPixel: palette image not supported.", Qnil, Qnil); |
10847 } | 10857 } |
10848 | 10858 |
10849 /* Create IMG->pixmap from an array COLORS of XColor structures, whose | 10859 /* Create IMG->pixmap from an array COLORS of XColor structures, whose |
10850 RGB members are set. F is the frame on which this all happens. | 10860 RGB members are set. F is the frame on which this all happens. |
10851 COLORS will be freed; an existing IMG->pixmap will be freed, too. */ | 10861 COLORS will be freed; an existing IMG->pixmap will be freed, too. */ |
11623 png_load, | 11633 png_load, |
11624 x_clear_image, | 11634 x_clear_image, |
11625 NULL | 11635 NULL |
11626 }; | 11636 }; |
11627 | 11637 |
11638 /* PNG library details. */ | |
11639 | |
11640 DEF_IMGLIB_FN (png_get_io_ptr); | |
11641 DEF_IMGLIB_FN (png_check_sig); | |
11642 DEF_IMGLIB_FN (png_create_read_struct); | |
11643 DEF_IMGLIB_FN (png_create_info_struct); | |
11644 DEF_IMGLIB_FN (png_destroy_read_struct); | |
11645 DEF_IMGLIB_FN (png_set_read_fn); | |
11646 DEF_IMGLIB_FN (png_init_io); | |
11647 DEF_IMGLIB_FN (png_set_sig_bytes); | |
11648 DEF_IMGLIB_FN (png_read_info); | |
11649 DEF_IMGLIB_FN (png_get_IHDR); | |
11650 DEF_IMGLIB_FN (png_get_valid); | |
11651 DEF_IMGLIB_FN (png_set_strip_16); | |
11652 DEF_IMGLIB_FN (png_set_expand); | |
11653 DEF_IMGLIB_FN (png_set_gray_to_rgb); | |
11654 DEF_IMGLIB_FN (png_set_background); | |
11655 DEF_IMGLIB_FN (png_get_bKGD); | |
11656 DEF_IMGLIB_FN (png_read_update_info); | |
11657 DEF_IMGLIB_FN (png_get_channels); | |
11658 DEF_IMGLIB_FN (png_get_rowbytes); | |
11659 DEF_IMGLIB_FN (png_read_image); | |
11660 DEF_IMGLIB_FN (png_read_end); | |
11661 DEF_IMGLIB_FN (png_error); | |
11662 | |
11663 static int | |
11664 init_png_functions (library) | |
11665 HMODULE library; | |
11666 { | |
11667 LOAD_IMGLIB_FN (library, png_get_io_ptr); | |
11668 LOAD_IMGLIB_FN (library, png_check_sig); | |
11669 LOAD_IMGLIB_FN (library, png_create_read_struct); | |
11670 LOAD_IMGLIB_FN (library, png_create_info_struct); | |
11671 LOAD_IMGLIB_FN (library, png_destroy_read_struct); | |
11672 LOAD_IMGLIB_FN (library, png_set_read_fn); | |
11673 LOAD_IMGLIB_FN (library, png_init_io); | |
11674 LOAD_IMGLIB_FN (library, png_set_sig_bytes); | |
11675 LOAD_IMGLIB_FN (library, png_read_info); | |
11676 LOAD_IMGLIB_FN (library, png_get_IHDR); | |
11677 LOAD_IMGLIB_FN (library, png_get_valid); | |
11678 LOAD_IMGLIB_FN (library, png_set_strip_16); | |
11679 LOAD_IMGLIB_FN (library, png_set_expand); | |
11680 LOAD_IMGLIB_FN (library, png_set_gray_to_rgb); | |
11681 LOAD_IMGLIB_FN (library, png_set_background); | |
11682 LOAD_IMGLIB_FN (library, png_get_bKGD); | |
11683 LOAD_IMGLIB_FN (library, png_read_update_info); | |
11684 LOAD_IMGLIB_FN (library, png_get_channels); | |
11685 LOAD_IMGLIB_FN (library, png_get_rowbytes); | |
11686 LOAD_IMGLIB_FN (library, png_read_image); | |
11687 LOAD_IMGLIB_FN (library, png_read_end); | |
11688 LOAD_IMGLIB_FN (library, png_error); | |
11689 return 1; | |
11690 } | |
11628 | 11691 |
11629 /* Return non-zero if OBJECT is a valid PNG image specification. */ | 11692 /* Return non-zero if OBJECT is a valid PNG image specification. */ |
11630 | 11693 |
11631 static int | 11694 static int |
11632 png_image_p (object) | 11695 png_image_p (object) |
11685 png_structp png_ptr; | 11748 png_structp png_ptr; |
11686 png_bytep data; | 11749 png_bytep data; |
11687 png_size_t length; | 11750 png_size_t length; |
11688 { | 11751 { |
11689 struct png_memory_storage *tbr | 11752 struct png_memory_storage *tbr |
11690 = (struct png_memory_storage *) png_get_io_ptr (png_ptr); | 11753 = (struct png_memory_storage *) fn_png_get_io_ptr (png_ptr); |
11691 | 11754 |
11692 if (length > tbr->len - tbr->index) | 11755 if (length > tbr->len - tbr->index) |
11693 png_error (png_ptr, "Read error"); | 11756 fn_png_error (png_ptr, "Read error"); |
11694 | 11757 |
11695 bcopy (tbr->bytes + tbr->index, data, length); | 11758 bcopy (tbr->bytes + tbr->index, data, length); |
11696 tbr->index = tbr->index + length; | 11759 tbr->index = tbr->index + length; |
11697 } | 11760 } |
11698 | 11761 |
11750 return 0; | 11813 return 0; |
11751 } | 11814 } |
11752 | 11815 |
11753 /* Check PNG signature. */ | 11816 /* Check PNG signature. */ |
11754 if (fread (sig, 1, sizeof sig, fp) != sizeof sig | 11817 if (fread (sig, 1, sizeof sig, fp) != sizeof sig |
11755 || !png_check_sig (sig, sizeof sig)) | 11818 || !fn_png_check_sig (sig, sizeof sig)) |
11756 { | 11819 { |
11757 image_error ("Not a PNG file: `%s'", file, Qnil); | 11820 image_error ("Not a PNG file: `%s'", file, Qnil); |
11758 UNGCPRO; | 11821 UNGCPRO; |
11759 fclose (fp); | 11822 fclose (fp); |
11760 return 0; | 11823 return 0; |
11767 tbr.len = SBYTES (specified_data); | 11830 tbr.len = SBYTES (specified_data); |
11768 tbr.index = 0; | 11831 tbr.index = 0; |
11769 | 11832 |
11770 /* Check PNG signature. */ | 11833 /* Check PNG signature. */ |
11771 if (tbr.len < sizeof sig | 11834 if (tbr.len < sizeof sig |
11772 || !png_check_sig (tbr.bytes, sizeof sig)) | 11835 || !fn_png_check_sig (tbr.bytes, sizeof sig)) |
11773 { | 11836 { |
11774 image_error ("Not a PNG image: `%s'", img->spec, Qnil); | 11837 image_error ("Not a PNG image: `%s'", img->spec, Qnil); |
11775 UNGCPRO; | 11838 UNGCPRO; |
11776 return 0; | 11839 return 0; |
11777 } | 11840 } |
11779 /* Need to skip past the signature. */ | 11842 /* Need to skip past the signature. */ |
11780 tbr.bytes += sizeof (sig); | 11843 tbr.bytes += sizeof (sig); |
11781 } | 11844 } |
11782 | 11845 |
11783 /* Initialize read and info structs for PNG lib. */ | 11846 /* Initialize read and info structs for PNG lib. */ |
11784 png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, | 11847 png_ptr = fn_png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, |
11785 my_png_error, my_png_warning); | 11848 my_png_error, my_png_warning); |
11786 if (!png_ptr) | 11849 if (!png_ptr) |
11787 { | 11850 { |
11788 if (fp) fclose (fp); | 11851 if (fp) fclose (fp); |
11789 UNGCPRO; | 11852 UNGCPRO; |
11790 return 0; | 11853 return 0; |
11791 } | 11854 } |
11792 | 11855 |
11793 info_ptr = png_create_info_struct (png_ptr); | 11856 info_ptr = fn_png_create_info_struct (png_ptr); |
11794 if (!info_ptr) | 11857 if (!info_ptr) |
11795 { | 11858 { |
11796 png_destroy_read_struct (&png_ptr, NULL, NULL); | 11859 fn_png_destroy_read_struct (&png_ptr, NULL, NULL); |
11797 if (fp) fclose (fp); | 11860 if (fp) fclose (fp); |
11798 UNGCPRO; | 11861 UNGCPRO; |
11799 return 0; | 11862 return 0; |
11800 } | 11863 } |
11801 | 11864 |
11802 end_info = png_create_info_struct (png_ptr); | 11865 end_info = fn_png_create_info_struct (png_ptr); |
11803 if (!end_info) | 11866 if (!end_info) |
11804 { | 11867 { |
11805 png_destroy_read_struct (&png_ptr, &info_ptr, NULL); | 11868 fn_png_destroy_read_struct (&png_ptr, &info_ptr, NULL); |
11806 if (fp) fclose (fp); | 11869 if (fp) fclose (fp); |
11807 UNGCPRO; | 11870 UNGCPRO; |
11808 return 0; | 11871 return 0; |
11809 } | 11872 } |
11810 | 11873 |
11812 detects an error. */ | 11875 detects an error. */ |
11813 if (setjmp (png_ptr->jmpbuf)) | 11876 if (setjmp (png_ptr->jmpbuf)) |
11814 { | 11877 { |
11815 error: | 11878 error: |
11816 if (png_ptr) | 11879 if (png_ptr) |
11817 png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); | 11880 fn_png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); |
11818 xfree (pixels); | 11881 xfree (pixels); |
11819 xfree (rows); | 11882 xfree (rows); |
11820 if (fp) fclose (fp); | 11883 if (fp) fclose (fp); |
11821 UNGCPRO; | 11884 UNGCPRO; |
11822 return 0; | 11885 return 0; |
11823 } | 11886 } |
11824 | 11887 |
11825 /* Read image info. */ | 11888 /* Read image info. */ |
11826 if (!NILP (specified_data)) | 11889 if (!NILP (specified_data)) |
11827 png_set_read_fn (png_ptr, (void *) &tbr, png_read_from_memory); | 11890 fn_png_set_read_fn (png_ptr, (void *) &tbr, png_read_from_memory); |
11828 else | 11891 else |
11829 png_init_io (png_ptr, fp); | 11892 fn_png_init_io (png_ptr, fp); |
11830 | 11893 |
11831 png_set_sig_bytes (png_ptr, sizeof sig); | 11894 fn_png_set_sig_bytes (png_ptr, sizeof sig); |
11832 png_read_info (png_ptr, info_ptr); | 11895 fn_png_read_info (png_ptr, info_ptr); |
11833 png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, | 11896 fn_png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, |
11834 &interlace_type, NULL, NULL); | 11897 &interlace_type, NULL, NULL); |
11835 | 11898 |
11836 /* If image contains simply transparency data, we prefer to | 11899 /* If image contains simply transparency data, we prefer to |
11837 construct a clipping mask. */ | 11900 construct a clipping mask. */ |
11838 if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) | 11901 if (fn_png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) |
11839 transparent_p = 1; | 11902 transparent_p = 1; |
11840 else | 11903 else |
11841 transparent_p = 0; | 11904 transparent_p = 0; |
11842 | 11905 |
11843 /* This function is easier to write if we only have to handle | 11906 /* This function is easier to write if we only have to handle |
11844 one data format: RGB or RGBA with 8 bits per channel. Let's | 11907 one data format: RGB or RGBA with 8 bits per channel. Let's |
11845 transform other formats into that format. */ | 11908 transform other formats into that format. */ |
11846 | 11909 |
11847 /* Strip more than 8 bits per channel. */ | 11910 /* Strip more than 8 bits per channel. */ |
11848 if (bit_depth == 16) | 11911 if (bit_depth == 16) |
11849 png_set_strip_16 (png_ptr); | 11912 fn_png_set_strip_16 (png_ptr); |
11850 | 11913 |
11851 /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha channel | 11914 /* Expand data to 24 bit RGB, or 8 bit grayscale, with alpha channel |
11852 if available. */ | 11915 if available. */ |
11853 png_set_expand (png_ptr); | 11916 fn_png_set_expand (png_ptr); |
11854 | 11917 |
11855 /* Convert grayscale images to RGB. */ | 11918 /* Convert grayscale images to RGB. */ |
11856 if (color_type == PNG_COLOR_TYPE_GRAY | 11919 if (color_type == PNG_COLOR_TYPE_GRAY |
11857 || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) | 11920 || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) |
11858 png_set_gray_to_rgb (png_ptr); | 11921 fn_png_set_gray_to_rgb (png_ptr); |
11859 | 11922 |
11860 screen_gamma = (f->gamma ? 1 / f->gamma / 0.45455 : 2.2); | 11923 screen_gamma = (f->gamma ? 1 / f->gamma / 0.45455 : 2.2); |
11861 | 11924 |
11862 #if 0 /* Avoid double gamma correction for PNG images. */ | 11925 #if 0 /* Avoid double gamma correction for PNG images. */ |
11863 /* Tell the PNG lib to handle gamma correction for us. */ | 11926 /* Tell the PNG lib to handle gamma correction for us. */ |
11895 bzero (&user_bg, sizeof user_bg); | 11958 bzero (&user_bg, sizeof user_bg); |
11896 user_bg.red = 256 * GetRValue (color); | 11959 user_bg.red = 256 * GetRValue (color); |
11897 user_bg.green = 256 * GetGValue (color); | 11960 user_bg.green = 256 * GetGValue (color); |
11898 user_bg.blue = 256 * GetBValue (color); | 11961 user_bg.blue = 256 * GetBValue (color); |
11899 | 11962 |
11900 png_set_background (png_ptr, &user_bg, | 11963 fn_png_set_background (png_ptr, &user_bg, |
11901 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); | 11964 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); |
11902 } | 11965 } |
11903 } | 11966 } |
11904 else if (png_get_bKGD (png_ptr, info_ptr, &image_bg)) | 11967 else if (fn_png_get_bKGD (png_ptr, info_ptr, &image_bg)) |
11905 /* Image contains a background color with which to | 11968 /* Image contains a background color with which to |
11906 combine the image. */ | 11969 combine the image. */ |
11907 png_set_background (png_ptr, image_bg, | 11970 fn_png_set_background (png_ptr, image_bg, |
11908 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); | 11971 PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); |
11909 else | 11972 else |
11910 { | 11973 { |
11911 /* Image does not contain a background color with which | 11974 /* Image does not contain a background color with which |
11912 to combine the image data via an alpha channel. Use | 11975 to combine the image data via an alpha channel. Use |
11913 the frame's background instead. */ | 11976 the frame's background instead. */ |
11924 bzero (&frame_background, sizeof frame_background); | 11987 bzero (&frame_background, sizeof frame_background); |
11925 frame_background.red = 256 * GetRValue (color); | 11988 frame_background.red = 256 * GetRValue (color); |
11926 frame_background.green = 256 * GetGValue (color); | 11989 frame_background.green = 256 * GetGValue (color); |
11927 frame_background.blue = 256 * GetBValue (color); | 11990 frame_background.blue = 256 * GetBValue (color); |
11928 | 11991 |
11929 png_set_background (png_ptr, &frame_background, | 11992 fn_png_set_background (png_ptr, &frame_background, |
11930 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); | 11993 PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); |
11931 } | 11994 } |
11932 } | 11995 } |
11933 | 11996 |
11934 /* Update info structure. */ | 11997 /* Update info structure. */ |
11935 png_read_update_info (png_ptr, info_ptr); | 11998 fn_png_read_update_info (png_ptr, info_ptr); |
11936 | 11999 |
11937 /* Get number of channels. Valid values are 1 for grayscale images | 12000 /* Get number of channels. Valid values are 1 for grayscale images |
11938 and images with a palette, 2 for grayscale images with transparency | 12001 and images with a palette, 2 for grayscale images with transparency |
11939 information (alpha channel), 3 for RGB images, and 4 for RGB | 12002 information (alpha channel), 3 for RGB images, and 4 for RGB |
11940 images with alpha channel, i.e. RGBA. If conversions above were | 12003 images with alpha channel, i.e. RGBA. If conversions above were |
11941 sufficient we should only have 3 or 4 channels here. */ | 12004 sufficient we should only have 3 or 4 channels here. */ |
11942 channels = png_get_channels (png_ptr, info_ptr); | 12005 channels = fn_png_get_channels (png_ptr, info_ptr); |
11943 xassert (channels == 3 || channels == 4); | 12006 xassert (channels == 3 || channels == 4); |
11944 | 12007 |
11945 /* Number of bytes needed for one row of the image. */ | 12008 /* Number of bytes needed for one row of the image. */ |
11946 row_bytes = png_get_rowbytes (png_ptr, info_ptr); | 12009 row_bytes = fn_png_get_rowbytes (png_ptr, info_ptr); |
11947 | 12010 |
11948 /* Allocate memory for the image. */ | 12011 /* Allocate memory for the image. */ |
11949 pixels = (png_byte *) xmalloc (row_bytes * height * sizeof *pixels); | 12012 pixels = (png_byte *) xmalloc (row_bytes * height * sizeof *pixels); |
11950 rows = (png_byte **) xmalloc (height * sizeof *rows); | 12013 rows = (png_byte **) xmalloc (height * sizeof *rows); |
11951 for (i = 0; i < height; ++i) | 12014 for (i = 0; i < height; ++i) |
11952 rows[i] = pixels + i * row_bytes; | 12015 rows[i] = pixels + i * row_bytes; |
11953 | 12016 |
11954 /* Read the entire image. */ | 12017 /* Read the entire image. */ |
11955 png_read_image (png_ptr, rows); | 12018 fn_png_read_image (png_ptr, rows); |
11956 png_read_end (png_ptr, info_ptr); | 12019 fn_png_read_end (png_ptr, info_ptr); |
11957 if (fp) | 12020 if (fp) |
11958 { | 12021 { |
11959 fclose (fp); | 12022 fclose (fp); |
11960 fp = NULL; | 12023 fp = NULL; |
11961 } | 12024 } |
12026 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) | 12089 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) |
12027 /* Set IMG's background color from the PNG image, unless the user | 12090 /* Set IMG's background color from the PNG image, unless the user |
12028 overrode it. */ | 12091 overrode it. */ |
12029 { | 12092 { |
12030 png_color_16 *bg; | 12093 png_color_16 *bg; |
12031 if (png_get_bKGD (png_ptr, info_ptr, &bg)) | 12094 if (fn_png_get_bKGD (png_ptr, info_ptr, &bg)) |
12032 { | 12095 { |
12033 #if 0 /* TODO: Color tables. */ | 12096 #if 0 /* TODO: Color tables. */ |
12034 img->background = lookup_rgb_color (f, bg->red, bg->green, bg->blue); | 12097 img->background = lookup_rgb_color (f, bg->red, bg->green, bg->blue); |
12035 #else | 12098 #else |
12036 img->background = PALETTERGB (bg->red / 256, bg->green / 256, | 12099 img->background = PALETTERGB (bg->red / 256, bg->green / 256, |
12045 img->colors = colors_in_color_table (&img->ncolors); | 12108 img->colors = colors_in_color_table (&img->ncolors); |
12046 free_color_table (); | 12109 free_color_table (); |
12047 #endif | 12110 #endif |
12048 | 12111 |
12049 /* Clean up. */ | 12112 /* Clean up. */ |
12050 png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); | 12113 fn_png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); |
12051 xfree (rows); | 12114 xfree (rows); |
12052 xfree (pixels); | 12115 xfree (pixels); |
12053 | 12116 |
12054 img->width = width; | 12117 img->width = width; |
12055 img->height = height; | 12118 img->height = height; |
13119 /*********************************************************************** | 13182 /*********************************************************************** |
13120 Ghostscript | 13183 Ghostscript |
13121 ***********************************************************************/ | 13184 ***********************************************************************/ |
13122 | 13185 |
13123 Lisp_Object Qpostscript; | 13186 Lisp_Object Qpostscript; |
13187 | |
13188 /* Keyword symbols. */ | |
13189 | |
13190 Lisp_Object QCloader, QCbounding_box, QCpt_width, QCpt_height; | |
13124 | 13191 |
13125 #ifdef HAVE_GHOSTSCRIPT | 13192 #ifdef HAVE_GHOSTSCRIPT |
13126 static int gs_image_p P_ ((Lisp_Object object)); | 13193 static int gs_image_p P_ ((Lisp_Object object)); |
13127 static int gs_load P_ ((struct frame *f, struct image *img)); | 13194 static int gs_load P_ ((struct frame *f, struct image *img)); |
13128 static void gs_clear_image P_ ((struct frame *f, struct image *img)); | 13195 static void gs_clear_image P_ ((struct frame *f, struct image *img)); |
15474 staticpro (&QCmargin); | 15541 staticpro (&QCmargin); |
15475 QCrelief = intern (":relief"); | 15542 QCrelief = intern (":relief"); |
15476 staticpro (&QCrelief); | 15543 staticpro (&QCrelief); |
15477 Qpostscript = intern ("postscript"); | 15544 Qpostscript = intern ("postscript"); |
15478 staticpro (&Qpostscript); | 15545 staticpro (&Qpostscript); |
15479 #if 0 /* TODO: These need entries at top of file. */ | |
15480 QCloader = intern (":loader"); | 15546 QCloader = intern (":loader"); |
15481 staticpro (&QCloader); | 15547 staticpro (&QCloader); |
15482 QCbounding_box = intern (":bounding-box"); | 15548 QCbounding_box = intern (":bounding-box"); |
15483 staticpro (&QCbounding_box); | 15549 staticpro (&QCbounding_box); |
15484 QCpt_width = intern (":pt-width"); | 15550 QCpt_width = intern (":pt-width"); |
15485 staticpro (&QCpt_width); | 15551 staticpro (&QCpt_width); |
15486 QCpt_height = intern (":pt-height"); | 15552 QCpt_height = intern (":pt-height"); |
15487 staticpro (&QCpt_height); | 15553 staticpro (&QCpt_height); |
15488 #endif | |
15489 QCindex = intern (":index"); | 15554 QCindex = intern (":index"); |
15490 staticpro (&QCindex); | 15555 staticpro (&QCindex); |
15491 Qpbm = intern ("pbm"); | 15556 Qpbm = intern ("pbm"); |
15492 staticpro (&Qpbm); | 15557 staticpro (&Qpbm); |
15493 | 15558 |
15557 it dynamically. Do it once, here, instead of every time it is used. | 15622 it dynamically. Do it once, here, instead of every time it is used. |
15558 */ | 15623 */ |
15559 track_mouse_event_fn = (TrackMouseEvent_Proc) GetProcAddress (user32_lib, "TrackMouseEvent"); | 15624 track_mouse_event_fn = (TrackMouseEvent_Proc) GetProcAddress (user32_lib, "TrackMouseEvent"); |
15560 } | 15625 } |
15561 | 15626 |
15562 | 15627 /* Initialize image types. Based on which libraries are available. */ |
15563 void | 15628 static void |
15564 init_xfns () | 15629 init_external_image_libraries () |
15565 { | 15630 { |
15566 image_types = NULL; | 15631 HINSTANCE png_lib; |
15567 Vimage_types = Qnil; | |
15568 | |
15569 define_image_type (&pbm_type); | |
15570 define_image_type (&xbm_type); | |
15571 #if 0 /* TODO : Image support for W32 */ | |
15572 define_image_type (&gs_type); | |
15573 #endif | |
15574 | 15632 |
15575 #if HAVE_XPM | 15633 #if HAVE_XPM |
15576 define_image_type (&xpm_type); | 15634 define_image_type (&xpm_type); |
15577 #endif | 15635 #endif |
15578 | 15636 |
15587 #if HAVE_GIF | 15645 #if HAVE_GIF |
15588 define_image_type (&gif_type); | 15646 define_image_type (&gif_type); |
15589 #endif | 15647 #endif |
15590 | 15648 |
15591 #if HAVE_PNG | 15649 #if HAVE_PNG |
15592 define_image_type (&png_type); | 15650 /* Ensure zlib is loaded. Try debug version first. */ |
15651 if (!LoadLibrary ("zlibd.dll")) | |
15652 LoadLibrary ("zlib.dll"); | |
15653 | |
15654 /* Try loading libpng under probable names. */ | |
15655 if ((png_lib = LoadLibrary ("libpng13d.dll")) | |
15656 || (png_lib = LoadLibrary ("libpng13.dll")) | |
15657 || (png_lib = LoadLibrary ("libpng12d.dll")) | |
15658 || (png_lib = LoadLibrary ("libpng12.dll")) | |
15659 || (png_lib = LoadLibrary ("libpng.dll"))) | |
15660 { | |
15661 if (init_png_functions (png_lib)) | |
15662 define_image_type (&png_type); | |
15663 } | |
15593 #endif | 15664 #endif |
15665 } | |
15666 | |
15667 void | |
15668 init_xfns () | |
15669 { | |
15670 image_types = NULL; | |
15671 Vimage_types = Qnil; | |
15672 | |
15673 define_image_type (&pbm_type); | |
15674 define_image_type (&xbm_type); | |
15675 | |
15676 #if 0 /* TODO : Ghostscript support for W32 */ | |
15677 define_image_type (&gs_type); | |
15678 #endif | |
15679 | |
15680 /* Image types that rely on external libraries are loaded dynamically | |
15681 if the library is available. */ | |
15682 init_external_image_libraries (); | |
15594 } | 15683 } |
15595 | 15684 |
15596 #undef abort | 15685 #undef abort |
15597 | 15686 |
15598 void | 15687 void |