diff options
| author | Juanma Barranquero | 2003-01-31 10:59:13 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2003-01-31 10:59:13 +0000 |
| commit | 12b918b2e33eb1c113ed8962fac5a78d591dccbf (patch) | |
| tree | 566da61b20f26b7302c2cff66f10a6de5a277b40 /src | |
| parent | 53b375911222ca75e20c4427535dfafcd7c7bb19 (diff) | |
| download | emacs-12b918b2e33eb1c113ed8962fac5a78d591dccbf.tar.gz emacs-12b918b2e33eb1c113ed8962fac5a78d591dccbf.zip | |
(init_tiff_functions): New function.
(tiff_load): Adjust colors for Windows. Disable color table lookups. Call
library functions through pointers determined at runtime.
(init_external_image_libraries): Try to load libtiff.dll.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32fns.c | 72 |
1 files changed, 53 insertions, 19 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index a1072ca7bbb..d23c658b6b2 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -12621,6 +12621,28 @@ static struct image_type tiff_type = | |||
| 12621 | NULL | 12621 | NULL |
| 12622 | }; | 12622 | }; |
| 12623 | 12623 | ||
| 12624 | /* TIFF library details. */ | ||
| 12625 | DEF_IMGLIB_FN (TIFFSetErrorHandler); | ||
| 12626 | DEF_IMGLIB_FN (TIFFSetWarningHandler); | ||
| 12627 | DEF_IMGLIB_FN (TIFFOpen); | ||
| 12628 | DEF_IMGLIB_FN (TIFFClientOpen); | ||
| 12629 | DEF_IMGLIB_FN (TIFFGetField); | ||
| 12630 | DEF_IMGLIB_FN (TIFFReadRGBAImage); | ||
| 12631 | DEF_IMGLIB_FN (TIFFClose); | ||
| 12632 | |||
| 12633 | static int | ||
| 12634 | init_tiff_functions (library) | ||
| 12635 | HMODULE library; | ||
| 12636 | { | ||
| 12637 | LOAD_IMGLIB_FN (library, TIFFSetErrorHandler); | ||
| 12638 | LOAD_IMGLIB_FN (library, TIFFSetWarningHandler); | ||
| 12639 | LOAD_IMGLIB_FN (library, TIFFOpen); | ||
| 12640 | LOAD_IMGLIB_FN (library, TIFFClientOpen); | ||
| 12641 | LOAD_IMGLIB_FN (library, TIFFGetField); | ||
| 12642 | LOAD_IMGLIB_FN (library, TIFFReadRGBAImage); | ||
| 12643 | LOAD_IMGLIB_FN (library, TIFFClose); | ||
| 12644 | return 1; | ||
| 12645 | } | ||
| 12624 | 12646 | ||
| 12625 | /* Return non-zero if OBJECT is a valid TIFF image specification. */ | 12647 | /* Return non-zero if OBJECT is a valid TIFF image specification. */ |
| 12626 | 12648 | ||
| @@ -12800,8 +12822,8 @@ tiff_load (f, img) | |||
| 12800 | file = Qnil; | 12822 | file = Qnil; |
| 12801 | GCPRO1 (file); | 12823 | GCPRO1 (file); |
| 12802 | 12824 | ||
| 12803 | TIFFSetErrorHandler (tiff_error_handler); | 12825 | fn_TIFFSetErrorHandler (tiff_error_handler); |
| 12804 | TIFFSetWarningHandler (tiff_warning_handler); | 12826 | fn_TIFFSetWarningHandler (tiff_warning_handler); |
| 12805 | 12827 | ||
| 12806 | if (NILP (specified_data)) | 12828 | if (NILP (specified_data)) |
| 12807 | { | 12829 | { |
| @@ -12815,7 +12837,7 @@ tiff_load (f, img) | |||
| 12815 | } | 12837 | } |
| 12816 | 12838 | ||
| 12817 | /* Try to open the image file. */ | 12839 | /* Try to open the image file. */ |
| 12818 | tiff = TIFFOpen (SDATA (file), "r"); | 12840 | tiff = fn_TIFFOpen (SDATA (file), "r"); |
| 12819 | if (tiff == NULL) | 12841 | if (tiff == NULL) |
| 12820 | { | 12842 | { |
| 12821 | image_error ("Cannot open `%s'", file, Qnil); | 12843 | image_error ("Cannot open `%s'", file, Qnil); |
| @@ -12830,14 +12852,14 @@ tiff_load (f, img) | |||
| 12830 | memsrc.len = SBYTES (specified_data); | 12852 | memsrc.len = SBYTES (specified_data); |
| 12831 | memsrc.index = 0; | 12853 | memsrc.index = 0; |
| 12832 | 12854 | ||
| 12833 | tiff = TIFFClientOpen ("memory_source", "r", &memsrc, | 12855 | tiff = fn_TIFFClientOpen ("memory_source", "r", &memsrc, |
| 12834 | (TIFFReadWriteProc) tiff_read_from_memory, | 12856 | (TIFFReadWriteProc) tiff_read_from_memory, |
| 12835 | (TIFFReadWriteProc) tiff_write_from_memory, | 12857 | (TIFFReadWriteProc) tiff_write_from_memory, |
| 12836 | tiff_seek_in_memory, | 12858 | tiff_seek_in_memory, |
| 12837 | tiff_close_memory, | 12859 | tiff_close_memory, |
| 12838 | tiff_size_of_memory, | 12860 | tiff_size_of_memory, |
| 12839 | tiff_mmap_memory, | 12861 | tiff_mmap_memory, |
| 12840 | tiff_unmap_memory); | 12862 | tiff_unmap_memory); |
| 12841 | 12863 | ||
| 12842 | if (!tiff) | 12864 | if (!tiff) |
| 12843 | { | 12865 | { |
| @@ -12849,12 +12871,12 @@ tiff_load (f, img) | |||
| 12849 | 12871 | ||
| 12850 | /* Get width and height of the image, and allocate a raster buffer | 12872 | /* Get width and height of the image, and allocate a raster buffer |
| 12851 | of width x height 32-bit values. */ | 12873 | of width x height 32-bit values. */ |
| 12852 | TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width); | 12874 | fn_TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width); |
| 12853 | TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height); | 12875 | fn_TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height); |
| 12854 | buf = (uint32 *) xmalloc (width * height * sizeof *buf); | 12876 | buf = (uint32 *) xmalloc (width * height * sizeof *buf); |
| 12855 | 12877 | ||
| 12856 | rc = TIFFReadRGBAImage (tiff, width, height, buf, 0); | 12878 | rc = fn_TIFFReadRGBAImage (tiff, width, height, buf, 0); |
| 12857 | TIFFClose (tiff); | 12879 | fn_TIFFClose (tiff); |
| 12858 | if (!rc) | 12880 | if (!rc) |
| 12859 | { | 12881 | { |
| 12860 | image_error ("Error reading TIFF image `%s'", img->spec, Qnil); | 12882 | image_error ("Error reading TIFF image `%s'", img->spec, Qnil); |
| @@ -12871,8 +12893,10 @@ tiff_load (f, img) | |||
| 12871 | return 0; | 12893 | return 0; |
| 12872 | } | 12894 | } |
| 12873 | 12895 | ||
| 12896 | #if 0 /* TODO: Color tables. */ | ||
| 12874 | /* Initialize the color table. */ | 12897 | /* Initialize the color table. */ |
| 12875 | init_color_table (); | 12898 | init_color_table (); |
| 12899 | #endif | ||
| 12876 | 12900 | ||
| 12877 | /* Process the pixel raster. Origin is in the lower-left corner. */ | 12901 | /* Process the pixel raster. Origin is in the lower-left corner. */ |
| 12878 | for (y = 0; y < height; ++y) | 12902 | for (y = 0; y < height; ++y) |
| @@ -12882,16 +12906,22 @@ tiff_load (f, img) | |||
| 12882 | for (x = 0; x < width; ++x) | 12906 | for (x = 0; x < width; ++x) |
| 12883 | { | 12907 | { |
| 12884 | uint32 abgr = row[x]; | 12908 | uint32 abgr = row[x]; |
| 12885 | int r = TIFFGetR (abgr) << 8; | 12909 | int r = TIFFGetR (abgr); |
| 12886 | int g = TIFFGetG (abgr) << 8; | 12910 | int g = TIFFGetG (abgr); |
| 12887 | int b = TIFFGetB (abgr) << 8; | 12911 | int b = TIFFGetB (abgr); |
| 12912 | #if 0 /* TODO: Color tables. */ | ||
| 12888 | XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b)); | 12913 | XPutPixel (ximg, x, height - 1 - y, lookup_rgb_color (f, r, g, b)); |
| 12914 | #else | ||
| 12915 | XPutPixel (ximg, x, height - 1 - y, PALETTERGB (r, g, b)); | ||
| 12916 | #endif | ||
| 12889 | } | 12917 | } |
| 12890 | } | 12918 | } |
| 12891 | 12919 | ||
| 12920 | #if 0 /* TODO: Color tables. */ | ||
| 12892 | /* Remember the colors allocated for the image. Free the color table. */ | 12921 | /* Remember the colors allocated for the image. Free the color table. */ |
| 12893 | img->colors = colors_in_color_table (&img->ncolors); | 12922 | img->colors = colors_in_color_table (&img->ncolors); |
| 12894 | free_color_table (); | 12923 | free_color_table (); |
| 12924 | #endif | ||
| 12895 | 12925 | ||
| 12896 | img->width = width; | 12926 | img->width = width; |
| 12897 | img->height = height; | 12927 | img->height = height; |
| @@ -15719,7 +15749,11 @@ init_external_image_libraries () | |||
| 15719 | #endif | 15749 | #endif |
| 15720 | 15750 | ||
| 15721 | #if HAVE_TIFF | 15751 | #if HAVE_TIFF |
| 15722 | define_image_type (&tiff_type); | 15752 | if (library = LoadLibrary ("libtiff.dll")) |
| 15753 | { | ||
| 15754 | if (init_tiff_functions (library)) | ||
| 15755 | define_image_type (&tiff_type); | ||
| 15756 | } | ||
| 15723 | #endif | 15757 | #endif |
| 15724 | 15758 | ||
| 15725 | #if HAVE_GIF | 15759 | #if HAVE_GIF |