Mercurial > hg > xemacs-beta
comparison src/glyphs-x.c @ 215:1f0dabaa0855 r20-4b6
Import from CVS: tag r20-4b6
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:07:35 +0200 |
parents | 41ff10fd062f |
children | d44af0c54775 |
comparison
equal
deleted
inserted
replaced
214:c5d88c05e1e9 | 215:1f0dabaa0855 |
---|---|
55 #include "opaque.h" | 55 #include "opaque.h" |
56 | 56 |
57 #include "sysfile.h" | 57 #include "sysfile.h" |
58 | 58 |
59 #ifdef HAVE_IMAGEMAGICK | 59 #ifdef HAVE_IMAGEMAGICK |
60 #define HAVE_X11_MAGICK_IMAGE_H | 60 #include <magick.h> |
61 #endif /* HAVE_IMAGEMAGICK */ | 61 /*#include <image.h>*/ |
62 | |
63 #ifdef HAVE_X11_MAGICK_IMAGE_H | |
64 #include <magick/magick.h> | |
65 /* #include <image.h> */ | |
66 #include <assert.h> | 62 #include <assert.h> |
67 #endif | 63 #endif |
68 | 64 |
69 #define LISP_DEVICE_TO_X_SCREEN(dev) \ | 65 #define LISP_DEVICE_TO_X_SCREEN(dev) \ |
70 XDefaultScreenOfDisplay (DEVICE_X_DISPLAY (XDEVICE (dev))) | 66 XDefaultScreenOfDisplay (DEVICE_X_DISPLAY (XDEVICE (dev))) |
1733 } | 1729 } |
1734 | 1730 |
1735 return Qnil; | 1731 return Qnil; |
1736 } | 1732 } |
1737 | 1733 |
1738 static void XDitherImage(Image *image,XImage *ximage); | |
1739 | |
1740 static void | 1734 static void |
1741 imagick_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, | 1735 imagick_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, |
1742 Lisp_Object pointer_fg, Lisp_Object pointer_bg, | 1736 Lisp_Object pointer_fg, Lisp_Object pointer_bg, |
1743 int dest_mask, Lisp_Object domain) | 1737 int dest_mask, Lisp_Object domain) |
1744 { | 1738 { |
1787 unwind.image = ReadImage(&image_info); | 1781 unwind.image = ReadImage(&image_info); |
1788 if (unwind.image == (Image *) NULL) { | 1782 if (unwind.image == (Image *) NULL) { |
1789 signal_simple_error ("Unable to read image.",instantiator); | 1783 signal_simple_error ("Unable to read image.",instantiator); |
1790 } | 1784 } |
1791 | 1785 |
1786 #if 1 | |
1787 DescribeImage(unwind.image,stderr,1); | |
1788 #endif | |
1789 | |
1792 unwind.ximage = XCreateImage(dpy, DefaultVisualOfScreen (scr), | 1790 unwind.ximage = XCreateImage(dpy, DefaultVisualOfScreen (scr), |
1793 depth, | 1791 depth, |
1794 (depth == 1) ? XYPixmap : ZPixmap, | 1792 (depth == 1) ? XYPixmap : ZPixmap, |
1795 0, 0, | 1793 0, 0, |
1796 unwind.image->columns, | 1794 unwind.image->columns, |
1817 ** FIXME IM FUCKED | 1815 ** FIXME IM FUCKED |
1818 ** | 1816 ** |
1819 ** WMP 10/30/97 | 1817 ** WMP 10/30/97 |
1820 */ | 1818 */ |
1821 | 1819 |
1820 { | |
1821 int i,j,x; | |
1822 unsigned int bytes_per_pixel, scanline_pad; | |
1823 unsigned char *q; | |
1824 RunlengthPacket *p; | |
1825 XColor color; | |
1826 | |
1827 unwind.npixels = unwind.image->total_colors; | |
1828 unwind.pixels = xmalloc(unwind.npixels * sizeof(unsigned long)); | |
1829 q = (unsigned char *) unwind.ximage->data; | |
1830 x = 0; | |
1831 memset(unwind.pixels,0,unwind.npixels * sizeof(unsigned long)); | |
1832 p = unwind.image->pixels; | |
1833 scanline_pad = unwind.ximage->bytes_per_line - | |
1834 ((unwind.ximage->width * unwind.ximage->bits_per_pixel) >> 3); | |
1835 | |
1836 /* Convert to multi-byte color-mapped X image. */ | |
1837 bytes_per_pixel=unwind.ximage->bits_per_pixel >> 3; | |
1838 | |
1839 #if 1 | |
1840 for (i=0; i < unwind.image->packets; i++) | |
1841 { | |
1842 color.red = p->red; | |
1843 color.green = p->green; | |
1844 color.blue = p->blue; | |
1845 color.flags = DoRed | DoGreen | DoBlue; | |
1846 allocate_nearest_color (dpy, DefaultColormapOfScreen (scr), &color); | |
1847 unwind.pixels[i] = color.pixel; | |
1848 | |
1849 for (j=0; j <= ((int) p->length); j++) | |
1850 { | |
1851 *q++=(unsigned char) color.pixel; | |
1852 x++; | |
1853 if (x == unwind.ximage->width) | |
1854 { | |
1855 x=0; | |
1856 q+=scanline_pad; | |
1857 } | |
1858 } | |
1859 p++; | |
1860 } | |
1861 #else | |
1862 for (i=0; i < unwind.image->packets; i++) | |
1863 { | |
1864 pixel = unwind.pixels[p->index]; | |
1865 for (k=0; k < bytes_per_pixel; k++) | |
1866 { | |
1867 channel[k]=(unsigned char) pixel; | |
1868 pixel>>=8; | |
1869 } | |
1870 for (j=0; j <= ((int) p->length); j++) | |
1871 { | |
1872 for (k=0; k < bytes_per_pixel; k++) | |
1873 *q++=channel[k]; | |
1874 x++; | |
1875 if (x == unwind.ximage->width) | |
1876 { | |
1877 x=0; | |
1878 q+=scanline_pad; | |
1879 } | |
1880 } | |
1881 p++; | |
1882 } | |
1883 #endif | |
1884 } | |
1885 | |
1822 init_image_instance_from_x_image (ii, unwind.ximage, dest_mask, | 1886 init_image_instance_from_x_image (ii, unwind.ximage, dest_mask, |
1823 unwind.pixels, unwind.npixels, | 1887 unwind.pixels, unwind.npixels, |
1824 instantiator); | 1888 instantiator); |
1889 | |
1890 /* And we are done! | |
1891 ** Now that we've succeeded, we don't want the pixels | |
1892 ** freed right now. They're kept around in the image instance | |
1893 ** structure until it's destroyed. | |
1894 */ | |
1895 unwind.npixels = 0; | |
1896 unbind_to (speccount, Qnil); | |
1825 } | 1897 } |
1826 | 1898 |
1827 #endif /* HAVE_IMAGEMAGICK */ | 1899 #endif /* HAVE_IMAGEMAGICK */ |
1828 | 1900 |
1829 | 1901 |