fi
+### Use -lrsvg-2 if available, unless `--with-rsvg=no' is specified.
+HAVE_RSVG=no
+if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" = "mingw32"; then
+ if test "${with_rsvg}" != "no"; then
+ RSVG_REQUIRED=2.11.0
+ RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
+
+ EMACS_CHECK_MODULES([RSVG], [$RSVG_MODULE])
+ AC_SUBST(RSVG_CFLAGS)
+ AC_SUBST(RSVG_LIBS)
+
+ if test $HAVE_RSVG = yes; then
+ AC_DEFINE(HAVE_RSVG, 1, [Define to 1 if using librsvg.])
+ CFLAGS="$CFLAGS $RSVG_CFLAGS"
+ # Windows loads librsvg dynamically
+ if test "${opsys}" = "mingw32"; then
+ RSVG_LIBS=
+ fi
+ fi
+ fi
+fi
+
HAVE_IMAGEMAGICK=no
if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${HAVE_W32}" = "yes"; then
if test "${with_imagemagick}" != "no"; then
with_jpeg=no
with_gif=no
with_tiff=no
- with_rsvg=no
CFLAGS="$CFLAGS $CAIRO_CFLAGS"
LIBS="$LIBS $CAIRO_LIBS"
fi
fi
-### Use -lrsvg-2 if available, unless `--with-rsvg=no' is specified.
-HAVE_RSVG=no
-if test "${HAVE_X11}" = "yes" || test "${HAVE_NS}" = "yes" || test "${opsys}" = "mingw32"; then
- if test "${with_rsvg}" != "no"; then
- RSVG_REQUIRED=2.11.0
- RSVG_MODULE="librsvg-2.0 >= $RSVG_REQUIRED"
-
- EMACS_CHECK_MODULES([RSVG], [$RSVG_MODULE])
- AC_SUBST(RSVG_CFLAGS)
- AC_SUBST(RSVG_LIBS)
-
- if test $HAVE_RSVG = yes; then
- AC_DEFINE(HAVE_RSVG, 1, [Define to 1 if using librsvg.])
- CFLAGS="$CFLAGS $RSVG_CFLAGS"
- # Windows loads librsvg dynamically
- if test "${opsys}" = "mingw32"; then
- RSVG_LIBS=
- fi
- fi
- fi
-fi
-
-
### Use -lXpm if available, unless `--with-xpm=no'.
### mingw32 doesn't use -lXpm, since it loads the library dynamically.
### In the Cygwin-w32 build, we need to use /usr/include/noX/X11/xpm.h
+2015-04-05 Jan Djärv <jan.h.d@swipnet.se>
+
+ * image.c: #undef COLOR_TABLE_SUPPORT when USE_CAIRO.
+ (x_clear_image): Free cr_data and cr_data2 if set.
+ (xpm_load): Assign data to cr_data2.
+ (svg_load_image): Convert from GdkPixbuf to CAIRO_FORMAT_ARGB32.
+
+ * dispextern.h (struct image): add cr_data2 if cairo.
+
2015-04-03 Jan Djärv <jan.h.d@swipnet.se>
* image.c (prepare_image_for_display): Don't load if USE_CAIRO.
#endif /* HAVE_NTGUI */
+#ifdef USE_CAIRO
+#undef COLOR_TABLE_SUPPORT
+#endif
+
#ifdef HAVE_NS
#undef COLOR_TABLE_SUPPORT
block_input ();
#ifdef USE_CAIRO
if (img->cr_data)
- {
- cairo_surface_destroy ((cairo_surface_t *)img->cr_data);
- if (img->ximg && img->ximg->obdata) xfree (img->ximg->obdata);
- }
+ cairo_surface_destroy ((cairo_surface_t *)img->cr_data);
+ if (img->cr_data2) xfree (img->cr_data2);
#endif
x_clear_image_1 (f, img,
CLEAR_IMAGE_PIXMAP | CLEAR_IMAGE_MASK | CLEAR_IMAGE_COLORS);
img->height = cairo_image_surface_get_height (surface);
img->cr_data = surface;
img->pixmap = 0;
- img->ximg->obdata = (char *)data;
+ img->cr_data2 = data;
}
else
{
eassert (gdk_pixbuf_get_has_alpha (pixbuf));
eassert (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
+#ifdef USE_CAIRO
+ {
+ cairo_surface_t *surface;
+ cairo_format_t format = CAIRO_FORMAT_ARGB32;
+ int stride = cairo_format_stride_for_width (format, width);
+ unsigned char *data = (unsigned char *) xmalloc (width*height*4);
+ int y;
+
+ for (y = 0; y < height; ++y)
+ {
+ const guchar *iconptr = pixels + y * rowstride;
+ uint32_t *dataptr = (uint32_t *) (data + y * rowstride);
+ int x;
+
+ for (x = 0; x < width; ++x)
+ {
+ *dataptr = (iconptr[0] << 16)
+ | (iconptr[1] << 8)
+ | iconptr[2]
+ | (iconptr[3] << 24);
+ iconptr += 4;
+ ++dataptr;
+ }
+ }
+
+ surface = cairo_image_surface_create_for_data (data,
+ format,
+ width,
+ height,
+ stride);
+
+ g_object_unref (pixbuf);
+ img->width = width;
+ img->height = height;
+ img->cr_data = surface;
+ img->cr_data2 = data;
+ img->pixmap = 0;
+ }
+#else
/* Try to create a x pixmap to hold the svg pixmap. */
if (!image_create_x_image_and_pixmap (f, img, width, height, 0, &ximg, 0))
{
/* Put ximg into the image. */
image_put_x_image (f, img, ximg, 0);
+#endif /* ! USE_CAIRO */
return 1;
/* For each pixel of the image, look its color up in the
color table. After having done so, the color table will
contain an entry for each color used by the image. */
+#ifdef COLOR_TABLE_SUPPORT
for (y = 0; y < img->height; ++y)
for (x = 0; x < img->width; ++x)
{
unsigned long pixel = XGetPixel (ximg, x, y);
+
lookup_pixel_color (f, pixel);
}
/* Record colors in the image. Free color table and XImage. */
-#ifdef COLOR_TABLE_SUPPORT
img->colors = colors_in_color_table (&img->ncolors);
free_color_table ();
#endif