aboutsummaryrefslogtreecommitdiffstats
path: root/src/image.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/image.c')
-rw-r--r--src/image.c104
1 files changed, 23 insertions, 81 deletions
diff --git a/src/image.c b/src/image.c
index 6240c64b201..addb932f834 100644
--- a/src/image.c
+++ b/src/image.c
@@ -86,12 +86,6 @@ typedef struct w32_bitmap_record Bitmap_Record;
86#define x_defined_color w32_defined_color 86#define x_defined_color w32_defined_color
87#define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits) 87#define DefaultDepthOfScreen(screen) (one_w32_display_info.n_cbits)
88 88
89/* Versions of libpng, libgif, and libjpeg that we were compiled with,
90 or -1 if no PNG/GIF support was compiled in. This is tested by
91 w32-win.el to correctly set up the alist used to search for the
92 respective image libraries. */
93Lisp_Object Qlibpng_version, Qlibgif_version, Qlibjpeg_version;
94
95#endif /* HAVE_NTGUI */ 89#endif /* HAVE_NTGUI */
96 90
97#ifdef HAVE_NS 91#ifdef HAVE_NS
@@ -110,11 +104,6 @@ typedef struct ns_bitmap_record Bitmap_Record;
110#define DefaultDepthOfScreen(screen) x_display_list->n_planes 104#define DefaultDepthOfScreen(screen) x_display_list->n_planes
111#endif /* HAVE_NS */ 105#endif /* HAVE_NS */
112 106
113
114/* The symbol `postscript' identifying images of this type. */
115
116static Lisp_Object Qpostscript;
117
118static void x_disable_image (struct frame *, struct image *); 107static void x_disable_image (struct frame *, struct image *);
119static void x_edge_detection (struct frame *, struct image *, Lisp_Object, 108static void x_edge_detection (struct frame *, struct image *, Lisp_Object,
120 Lisp_Object); 109 Lisp_Object);
@@ -126,8 +115,6 @@ static void free_color_table (void);
126static unsigned long *colors_in_color_table (int *n); 115static unsigned long *colors_in_color_table (int *n);
127#endif 116#endif
128 117
129static Lisp_Object QCmax_width, QCmax_height;
130
131/* Code to deal with bitmaps. Bitmaps are referenced by their bitmap 118/* Code to deal with bitmaps. Bitmaps are referenced by their bitmap
132 id, which is just an int that this section returns. Bitmaps are 119 id, which is just an int that this section returns. Bitmaps are
133 reference counted so they can be shared among frames. 120 reference counted so they can be shared among frames.
@@ -537,24 +524,6 @@ x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
537 524
538static struct image_type *image_types; 525static struct image_type *image_types;
539 526
540/* The symbol `xbm' which is used as the type symbol for XBM images. */
541
542static Lisp_Object Qxbm;
543
544/* Keywords. */
545
546Lisp_Object QCascent, QCmargin, QCrelief;
547Lisp_Object QCconversion;
548static Lisp_Object QCheuristic_mask;
549static Lisp_Object QCcolor_symbols;
550static Lisp_Object QCindex, QCmatrix, QCcolor_adjustment, QCmask, QCgeometry;
551static Lisp_Object QCcrop, QCrotation;
552
553/* Other symbols. */
554
555static Lisp_Object Qcount, Qextension_data, Qdelay;
556static Lisp_Object Qlaplace, Qemboss, Qedge_detection, Qheuristic;
557
558/* Forward function prototypes. */ 527/* Forward function prototypes. */
559 528
560static struct image_type *lookup_image_type (Lisp_Object); 529static struct image_type *lookup_image_type (Lisp_Object);
@@ -579,27 +548,28 @@ static struct image_type *
579define_image_type (struct image_type *type) 548define_image_type (struct image_type *type)
580{ 549{
581 struct image_type *p = NULL; 550 struct image_type *p = NULL;
582 Lisp_Object target_type = *type->type; 551 struct Lisp_Symbol *new_type = type->type;
583 bool type_valid = 1; 552 bool type_valid = 1;
584 553
585 block_input (); 554 block_input ();
586 555
587 for (p = image_types; p; p = p->next) 556 for (p = image_types; p; p = p->next)
588 if (EQ (*p->type, target_type)) 557 if (p->type == new_type)
589 goto done; 558 goto done;
590 559
591 if (type->init) 560 if (type->init)
592 { 561 {
593#if defined HAVE_NTGUI && defined WINDOWSNT 562#if defined HAVE_NTGUI && defined WINDOWSNT
594 /* If we failed to load the library before, don't try again. */ 563 /* If we failed to load the library before, don't try again. */
595 Lisp_Object tested = Fassq (target_type, Vlibrary_cache); 564 Lisp_Object tested = Fassq (make_lisp_symbol (new_type), Vlibrary_cache);
596 if (CONSP (tested) && NILP (XCDR (tested))) 565 if (CONSP (tested) && NILP (XCDR (tested)))
597 type_valid = 0; 566 type_valid = 0;
598 else 567 else
599#endif 568#endif
600 { 569 {
601 type_valid = type->init (); 570 type_valid = type->init ();
602 CACHE_IMAGE_TYPE (target_type, type_valid ? Qt : Qnil); 571 CACHE_IMAGE_TYPE (make_lisp_symbol (new_type),
572 type_valid ? Qt : Qnil);
603 } 573 }
604 } 574 }
605 575
@@ -1777,7 +1747,7 @@ lookup_image (struct frame *f, Lisp_Object spec)
1777 1747
1778 /* Do image transformations and compute masks, unless we 1748 /* Do image transformations and compute masks, unless we
1779 don't have the image yet. */ 1749 don't have the image yet. */
1780 if (!EQ (*img->type->type, Qpostscript)) 1750 if (!EQ (make_lisp_symbol (img->type->type), Qpostscript))
1781 postprocess_image (f, img); 1751 postprocess_image (f, img);
1782 } 1752 }
1783 1753
@@ -2362,7 +2332,7 @@ static const struct image_keyword xbm_format[XBM_LAST] =
2362 2332
2363static struct image_type xbm_type = 2333static struct image_type xbm_type =
2364{ 2334{
2365 &Qxbm, 2335 XSYMBOL_INIT (Qxbm),
2366 xbm_image_p, 2336 xbm_image_p,
2367 xbm_load, 2337 xbm_load,
2368 x_clear_image, 2338 x_clear_image,
@@ -3121,9 +3091,6 @@ static bool xpm_load (struct frame *f, struct image *img);
3121#endif /* HAVE_XPM */ 3091#endif /* HAVE_XPM */
3122 3092
3123#if defined (HAVE_XPM) || defined (HAVE_NS) 3093#if defined (HAVE_XPM) || defined (HAVE_NS)
3124/* The symbol `xpm' identifying XPM-format images. */
3125
3126static Lisp_Object Qxpm;
3127 3094
3128/* Indices of image specification fields in xpm_format, below. */ 3095/* Indices of image specification fields in xpm_format, below. */
3129 3096
@@ -3171,7 +3138,7 @@ static bool init_xpm_functions (void);
3171 3138
3172static struct image_type xpm_type = 3139static struct image_type xpm_type =
3173{ 3140{
3174 &Qxpm, 3141 XSYMBOL_INIT (Qxpm),
3175 xpm_image_p, 3142 xpm_image_p,
3176 xpm_load, 3143 xpm_load,
3177 x_clear_image, 3144 x_clear_image,
@@ -5059,10 +5026,6 @@ x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
5059static bool pbm_image_p (Lisp_Object object); 5026static bool pbm_image_p (Lisp_Object object);
5060static bool pbm_load (struct frame *f, struct image *img); 5027static bool pbm_load (struct frame *f, struct image *img);
5061 5028
5062/* The symbol `pbm' identifying images of this type. */
5063
5064static Lisp_Object Qpbm;
5065
5066/* Indices of image specification fields in gs_format, below. */ 5029/* Indices of image specification fields in gs_format, below. */
5067 5030
5068enum pbm_keyword_index 5031enum pbm_keyword_index
@@ -5103,7 +5066,7 @@ static const struct image_keyword pbm_format[PBM_LAST] =
5103 5066
5104static struct image_type pbm_type = 5067static struct image_type pbm_type =
5105{ 5068{
5106 &Qpbm, 5069 XSYMBOL_INIT (Qpbm),
5107 pbm_image_p, 5070 pbm_image_p,
5108 pbm_load, 5071 pbm_load,
5109 x_clear_image, 5072 x_clear_image,
@@ -5446,10 +5409,6 @@ pbm_load (struct frame *f, struct image *img)
5446static bool png_image_p (Lisp_Object object); 5409static bool png_image_p (Lisp_Object object);
5447static bool png_load (struct frame *f, struct image *img); 5410static bool png_load (struct frame *f, struct image *img);
5448 5411
5449/* The symbol `png' identifying images of this type. */
5450
5451static Lisp_Object Qpng;
5452
5453/* Indices of image specification fields in png_format, below. */ 5412/* Indices of image specification fields in png_format, below. */
5454 5413
5455enum png_keyword_index 5414enum png_keyword_index
@@ -5494,7 +5453,7 @@ static bool init_png_functions (void);
5494 5453
5495static struct image_type png_type = 5454static struct image_type png_type =
5496{ 5455{
5497 &Qpng, 5456 XSYMBOL_INIT (Qpng),
5498 png_image_p, 5457 png_image_p,
5499 png_load, 5458 png_load,
5500 x_clear_image, 5459 x_clear_image,
@@ -6102,10 +6061,6 @@ png_load (struct frame *f, struct image *img)
6102static bool jpeg_image_p (Lisp_Object object); 6061static bool jpeg_image_p (Lisp_Object object);
6103static bool jpeg_load (struct frame *f, struct image *img); 6062static bool jpeg_load (struct frame *f, struct image *img);
6104 6063
6105/* The symbol `jpeg' identifying images of this type. */
6106
6107static Lisp_Object Qjpeg;
6108
6109/* Indices of image specification fields in gs_format, below. */ 6064/* Indices of image specification fields in gs_format, below. */
6110 6065
6111enum jpeg_keyword_index 6066enum jpeg_keyword_index
@@ -6150,7 +6105,7 @@ static bool init_jpeg_functions (void);
6150 6105
6151static struct image_type jpeg_type = 6106static struct image_type jpeg_type =
6152{ 6107{
6153 &Qjpeg, 6108 XSYMBOL_INIT (Qjpeg),
6154 jpeg_image_p, 6109 jpeg_image_p,
6155 jpeg_load, 6110 jpeg_load,
6156 x_clear_image, 6111 x_clear_image,
@@ -6704,10 +6659,6 @@ jpeg_load (struct frame *f, struct image *img)
6704static bool tiff_image_p (Lisp_Object object); 6659static bool tiff_image_p (Lisp_Object object);
6705static bool tiff_load (struct frame *f, struct image *img); 6660static bool tiff_load (struct frame *f, struct image *img);
6706 6661
6707/* The symbol `tiff' identifying images of this type. */
6708
6709static Lisp_Object Qtiff;
6710
6711/* Indices of image specification fields in tiff_format, below. */ 6662/* Indices of image specification fields in tiff_format, below. */
6712 6663
6713enum tiff_keyword_index 6664enum tiff_keyword_index
@@ -6754,7 +6705,7 @@ static bool init_tiff_functions (void);
6754 6705
6755static struct image_type tiff_type = 6706static struct image_type tiff_type =
6756{ 6707{
6757 &Qtiff, 6708 XSYMBOL_INIT (Qtiff),
6758 tiff_image_p, 6709 tiff_image_p,
6759 tiff_load, 6710 tiff_load,
6760 x_clear_image, 6711 x_clear_image,
@@ -7167,10 +7118,6 @@ static bool gif_image_p (Lisp_Object object);
7167static bool gif_load (struct frame *f, struct image *img); 7118static bool gif_load (struct frame *f, struct image *img);
7168static void gif_clear_image (struct frame *f, struct image *img); 7119static void gif_clear_image (struct frame *f, struct image *img);
7169 7120
7170/* The symbol `gif' identifying images of this type. */
7171
7172static Lisp_Object Qgif;
7173
7174/* Indices of image specification fields in gif_format, below. */ 7121/* Indices of image specification fields in gif_format, below. */
7175 7122
7176enum gif_keyword_index 7123enum gif_keyword_index
@@ -7217,7 +7164,7 @@ static bool init_gif_functions (void);
7217 7164
7218static struct image_type gif_type = 7165static struct image_type gif_type =
7219{ 7166{
7220 &Qgif, 7167 XSYMBOL_INIT (Qgif),
7221 gif_image_p, 7168 gif_image_p,
7222 gif_load, 7169 gif_load,
7223 gif_clear_image, 7170 gif_clear_image,
@@ -7841,8 +7788,6 @@ compute_image_size (size_t width, size_t height,
7841 *d_height = desired_height; 7788 *d_height = desired_height;
7842} 7789}
7843 7790
7844static Lisp_Object Qimagemagick;
7845
7846static bool imagemagick_image_p (Lisp_Object); 7791static bool imagemagick_image_p (Lisp_Object);
7847static bool imagemagick_load (struct frame *, struct image *); 7792static bool imagemagick_load (struct frame *, struct image *);
7848static void imagemagick_clear_image (struct frame *, struct image *); 7793static void imagemagick_clear_image (struct frame *, struct image *);
@@ -7906,7 +7851,7 @@ static bool init_imagemagick_functions (void);
7906 7851
7907static struct image_type imagemagick_type = 7852static struct image_type imagemagick_type =
7908 { 7853 {
7909 &Qimagemagick, 7854 XSYMBOL_INIT (Qimagemagick),
7910 imagemagick_image_p, 7855 imagemagick_image_p,
7911 imagemagick_load, 7856 imagemagick_load,
7912 imagemagick_clear_image, 7857 imagemagick_clear_image,
@@ -8632,10 +8577,6 @@ static bool svg_load (struct frame *f, struct image *img);
8632static bool svg_load_image (struct frame *, struct image *, 8577static bool svg_load_image (struct frame *, struct image *,
8633 unsigned char *, ptrdiff_t, char *); 8578 unsigned char *, ptrdiff_t, char *);
8634 8579
8635/* The symbol `svg' identifying images of this type. */
8636
8637static Lisp_Object Qsvg;
8638
8639/* Indices of image specification fields in svg_format, below. */ 8580/* Indices of image specification fields in svg_format, below. */
8640 8581
8641enum svg_keyword_index 8582enum svg_keyword_index
@@ -8682,7 +8623,7 @@ static bool init_svg_functions (void);
8682 8623
8683static struct image_type svg_type = 8624static struct image_type svg_type =
8684{ 8625{
8685 &Qsvg, 8626 XSYMBOL_INIT (Qsvg),
8686 svg_image_p, 8627 svg_image_p,
8687 svg_load, 8628 svg_load,
8688 x_clear_image, 8629 x_clear_image,
@@ -8737,8 +8678,6 @@ DEF_DLL_FN (void, g_type_init, (void));
8737DEF_DLL_FN (void, g_object_unref, (gpointer)); 8678DEF_DLL_FN (void, g_object_unref, (gpointer));
8738DEF_DLL_FN (void, g_error_free, (GError *)); 8679DEF_DLL_FN (void, g_error_free, (GError *));
8739 8680
8740Lisp_Object Qgdk_pixbuf, Qglib, Qgobject;
8741
8742static bool 8681static bool
8743init_svg_functions (void) 8682init_svg_functions (void)
8744{ 8683{
@@ -9056,10 +8995,6 @@ static bool gs_image_p (Lisp_Object object);
9056static bool gs_load (struct frame *f, struct image *img); 8995static bool gs_load (struct frame *f, struct image *img);
9057static void gs_clear_image (struct frame *f, struct image *img); 8996static void gs_clear_image (struct frame *f, struct image *img);
9058 8997
9059/* Keyword symbols. */
9060
9061static Lisp_Object QCloader, QCbounding_box, QCpt_width, QCpt_height;
9062
9063/* Indices of image specification fields in gs_format, below. */ 8998/* Indices of image specification fields in gs_format, below. */
9064 8999
9065enum gs_keyword_index 9000enum gs_keyword_index
@@ -9104,7 +9039,7 @@ static const struct image_keyword gs_format[GS_LAST] =
9104 9039
9105static struct image_type gs_type = 9040static struct image_type gs_type =
9106{ 9041{
9107 &Qpostscript, 9042 XSYMBOL_INIT (Qpostscript),
9108 gs_image_p, 9043 gs_image_p,
9109 gs_load, 9044 gs_load,
9110 gs_clear_image, 9045 gs_clear_image,
@@ -9479,10 +9414,12 @@ as a ratio to the frame height and width. If the value is
9479non-numeric, there is no explicit limit on the size of images. */); 9414non-numeric, there is no explicit limit on the size of images. */);
9480 Vmax_image_size = make_float (MAX_IMAGE_SIZE); 9415 Vmax_image_size = make_float (MAX_IMAGE_SIZE);
9481 9416
9417 /* Other symbols. */
9482 DEFSYM (Qcount, "count"); 9418 DEFSYM (Qcount, "count");
9483 DEFSYM (Qextension_data, "extension-data"); 9419 DEFSYM (Qextension_data, "extension-data");
9484 DEFSYM (Qdelay, "delay"); 9420 DEFSYM (Qdelay, "delay");
9485 9421
9422 /* Keywords. */
9486 DEFSYM (QCascent, ":ascent"); 9423 DEFSYM (QCascent, ":ascent");
9487 DEFSYM (QCmargin, ":margin"); 9424 DEFSYM (QCmargin, ":margin");
9488 DEFSYM (QCrelief, ":relief"); 9425 DEFSYM (QCrelief, ":relief");
@@ -9497,6 +9434,7 @@ non-numeric, there is no explicit limit on the size of images. */);
9497 DEFSYM (QCcolor_adjustment, ":color-adjustment"); 9434 DEFSYM (QCcolor_adjustment, ":color-adjustment");
9498 DEFSYM (QCmask, ":mask"); 9435 DEFSYM (QCmask, ":mask");
9499 9436
9437 /* Other symbols. */
9500 DEFSYM (Qlaplace, "laplace"); 9438 DEFSYM (Qlaplace, "laplace");
9501 DEFSYM (Qemboss, "emboss"); 9439 DEFSYM (Qemboss, "emboss");
9502 DEFSYM (Qedge_detection, "edge-detection"); 9440 DEFSYM (Qedge_detection, "edge-detection");
@@ -9514,6 +9452,10 @@ non-numeric, there is no explicit limit on the size of images. */);
9514#endif /* HAVE_GHOSTSCRIPT */ 9452#endif /* HAVE_GHOSTSCRIPT */
9515 9453
9516#ifdef HAVE_NTGUI 9454#ifdef HAVE_NTGUI
9455 /* Versions of libpng, libgif, and libjpeg that we were compiled with,
9456 or -1 if no PNG/GIF support was compiled in. This is tested by
9457 w32-win.el to correctly set up the alist used to search for the
9458 respective image libraries. */
9517 DEFSYM (Qlibpng_version, "libpng-version"); 9459 DEFSYM (Qlibpng_version, "libpng-version");
9518 Fset (Qlibpng_version, 9460 Fset (Qlibpng_version,
9519#if HAVE_PNG 9461#if HAVE_PNG