[goffice] Add some optional support for EPS images.
- From: Jean BrÃfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Add some optional support for EPS images.
- Date: Fri, 4 Nov 2011 13:15:17 +0000 (UTC)
commit 3bc4b26bbbb358d82e72dafd4e6f613e4b72e262
Author: Jean Brefort <jean brefort normalesup org>
Date: Fri Nov 4 14:14:37 2011 +0100
Add some optional support for EPS images.
ChangeLog | 15 +++++++++++++++
NEWS | 1 +
configure.in | 14 ++++++++++++++
goffice/component/go-component.c | 4 ++--
goffice/component/go-component.h | 2 --
goffice/goffice.c | 1 +
goffice/utils/Makefile.am | 2 ++
goffice/utils/go-image.c | 11 +++++++++--
goffice/utils/go-svg.c | 6 ++++--
goffice/utils/goffice-utils.h | 2 ++
10 files changed, 50 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b25c9a6..172ef78 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2011-11-04 Jean Brefort <jean brefort normalesup org>
+
+ * configure.in: add a test for libspectre presence.
+ * goffice/component/go-component.c (go_component_write_xml_sax),
+ (_go_component_start): remove obsolete GOC_PARAM_PERSISTENT.
+ * goffice/component/go-component.h: ditto.
+ * goffice/goffice.c (libgoffice_init): add GO_TYPE_SPECTRE.
+ * goffice/utils/Makefile.am: add go-spectre.[c,h]
+ * goffice/utils/go-image.c (go_image_new_from_file),
+ (go_image_new_from_data): create images form eps if libspectre is
+ present.
+ * goffice/utils/go-svg.c (go_svg_get_pixbuf),
+ (go_svg_get_scaled_pixbuf): fixed memory leak.
+ * goffice/utils/goffice-utils.h: add GOSpectre.
+
2011-11-03 Morten Welinder <terra gnome org>
* goffice/utils/go-glib-extras.c (go_hash_values): Remove.
diff --git a/NEWS b/NEWS
index fd52d21..77fb36a 100644
--- a/NEWS
+++ b/NEWS
@@ -37,6 +37,7 @@ Jean:
* Fix background images issues in graphs. [#660917]
* Make GSettings the default configuration backend.
* Add support for SVG images.
+ * Add some optional support for EPS images.
Morten:
* Recognize scientific formats with longer exponents.
diff --git a/configure.in b/configure.in
index cc51256..a7d180b 100644
--- a/configure.in
+++ b/configure.in
@@ -137,6 +137,20 @@ fi
AM_CONDITIONAL(GOFFICE_WITH_LASEM, $goffice_with_lasem)
+dnl ***************************
+dnl Should we use libspectre ?
+dnl ***************************
+
+goffice_with_eps=false
+PKG_CHECK_MODULES(EPS, libspectre >= 0.2.6)
+goffice_with_eps=true
+if test "x$goffice_with_eps" = "xtrue" ; then
+ AC_DEFINE(GOFFICE_WITH_EPS, 1, [Define if EPS is supported])
+ goffice_reqs="$goffice_reqs libspectre >= 0.2.6 "
+ EXTRA_DEPS="$EXTRA_DEPS libspectre"
+fi
+
+AM_CONDITIONAL(GOFFICE_WITH_EPS, $goffice_with_eps)
dnl *****************************
AC_MSG_CHECKING([for Win32 platform])
diff --git a/goffice/component/go-component.c b/goffice/component/go-component.c
index 6e9ca42..2dba21a 100644
--- a/goffice/component/go-component.c
+++ b/goffice/component/go-component.c
@@ -512,7 +512,7 @@ go_component_write_xml_sax (GOComponent *component, GsfXMLOut *output)
gsf_xml_out_add_float (output, "height", component->height, 3);
/* save needed component specific properties */
for (i = 0; i < nbprops; i++)
- if (specs[i]->flags & GOC_PARAM_PERSISTENT) {
+ if (specs[i]->flags & GO_PARAM_PERSISTENT) {
prop_type = G_PARAM_SPEC_VALUE_TYPE (specs[i]);
memset (&value, 0, sizeof (value));
g_value_init (&value, prop_type);
@@ -575,7 +575,7 @@ _go_component_start (GsfXMLIn *xin, xmlChar const **attrs)
memset (&res, 0, sizeof (res));
prop_spec = g_object_class_find_property (
G_OBJECT_GET_CLASS (state->component), attrs[i]);
- if (prop_spec && (prop_spec->flags & GOC_PARAM_PERSISTENT) &&
+ if (prop_spec && (prop_spec->flags & GO_PARAM_PERSISTENT) &&
gsf_xml_gvalue_from_str (&res,
G_TYPE_FUNDAMENTAL (G_PARAM_SPEC_VALUE_TYPE (prop_spec)),
attrs[i+1])) {
diff --git a/goffice/component/go-component.h b/goffice/component/go-component.h
index bacdbda..7377f98 100644
--- a/goffice/component/go-component.h
+++ b/goffice/component/go-component.h
@@ -86,8 +86,6 @@ typedef struct _GOComponentClass GOComponentClass;
#define GO_COMPONENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GO_TYPE_COMPONENT, GOComponent))
#define GO_IS_COMPONENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GO_TYPE_COMPONENT))
-#define GOC_PARAM_PERSISTENT (1 << (G_PARAM_USER_SHIFT+0))
-
GType go_component_get_type (void);
GOComponent *go_component_new_by_mime_type (char const *mime_type);
GOComponent *go_component_new_from_uri (char const *uri);
diff --git a/goffice/goffice.c b/goffice/goffice.c
index 83a3571..9357bc7 100644
--- a/goffice/goffice.c
+++ b/goffice/goffice.c
@@ -215,6 +215,7 @@ libgoffice_init (void)
(void) GOG_3D_BOX_TYPE;
(void) GO_TYPE_EMF;
(void) GO_TYPE_PIXBUF;
+ (void) GO_TYPE_SPECTRE;
(void) GO_TYPE_SVG;
_gog_themes_init ();
_go_number_format_init ();
diff --git a/goffice/utils/Makefile.am b/goffice/utils/Makefile.am
index 7b55bc6..ce8db5b 100644
--- a/goffice/utils/Makefile.am
+++ b/goffice/utils/Makefile.am
@@ -15,6 +15,7 @@ libgoffice_utils_la_SOURCES = \
go-pixbuf.c \
go-svg.c \
go-emf.c \
+ go-spectre.c \
go-line.c \
go-locale.c \
go-marker.c \
@@ -50,6 +51,7 @@ libgoffice_utils_la_HEADERS = \
go-pixbuf.h \
go-svg.h \
go-emf.h \
+ go-spectre.h \
go-line.h \
go-locale.h \
go-marker.h \
diff --git a/goffice/utils/go-image.c b/goffice/utils/go-image.c
index 1d211e6..b7071e7 100644
--- a/goffice/utils/go-image.c
+++ b/goffice/utils/go-image.c
@@ -434,9 +434,12 @@ go_image_new_from_file (char const *filename, GError **error)
case GO_IMAGE_FORMAT_EMF:
case GO_IMAGE_FORMAT_WMF:
return go_emf_new_from_file (filename, error);
- case GO_IMAGE_FORMAT_PDF:
- case GO_IMAGE_FORMAT_PS:
case GO_IMAGE_FORMAT_EPS:
+#ifdef GOFFICE_WITH_EPS
+ return go_spectre_new_from_file (filename, error);
+#endif
+ case GO_IMAGE_FORMAT_PS: /* we might support ps with libspectre */
+ case GO_IMAGE_FORMAT_PDF:
case GO_IMAGE_FORMAT_UNKNOWN:
break;
default: {
@@ -470,6 +473,10 @@ go_image_new_from_data (char const *type, guint8 const *data, gsize length, char
image = go_svg_new_from_data (data, length, error);
} else if (!strcmp (type, "emf") || !strcmp (type, "wmf")) {
image = go_emf_new_from_data (data, length, error);
+#ifdef GOFFICE_WITH_EPS
+ } else if (!strcmp (type, "eps")) {
+ image = go_spectre_new_from_data (data, length, error);
+#endif
} else {
/* FIXME: pixbuf */
}
diff --git a/goffice/utils/go-svg.c b/goffice/utils/go-svg.c
index c50ba61..603ffe5 100644
--- a/goffice/utils/go-svg.c
+++ b/goffice/utils/go-svg.c
@@ -87,10 +87,11 @@ go_svg_get_pixbuf (GOImage *image)
rsvg_handle_render_cairo (svg->handle, cr);
cairo_destroy (cr);
res = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, image->width, image->height);
- go_cairo_convert_data_from_pixbuf (gdk_pixbuf_get_pixels (res),
+ go_cairo_convert_data_to_pixbuf (gdk_pixbuf_get_pixels (res),
cairo_image_surface_get_data (surface),
image->width, image->height,
cairo_image_surface_get_stride (surface));
+ cairo_surface_destroy (surface);
return res;
}
@@ -108,10 +109,11 @@ go_svg_get_scaled_pixbuf (GOImage *image, int width, int height)
rsvg_handle_render_cairo (svg->handle, cr);
cairo_destroy (cr);
res = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
- go_cairo_convert_data_from_pixbuf (gdk_pixbuf_get_pixels (res),
+ go_cairo_convert_data_to_pixbuf (gdk_pixbuf_get_pixels (res),
cairo_image_surface_get_data (surface),
width, height,
cairo_image_surface_get_stride (surface));
+ cairo_surface_destroy (surface);
return res;
}
diff --git a/goffice/utils/goffice-utils.h b/goffice/utils/goffice-utils.h
index 7030a16..043f342 100644
--- a/goffice/utils/goffice-utils.h
+++ b/goffice/utils/goffice-utils.h
@@ -38,6 +38,7 @@ typedef struct _GOImage GOImage;
typedef struct _GOPixbuf GOPixbuf;
typedef struct _GOSvg GOSvg;
typedef struct _GOEmf GOEmf;
+typedef struct _GOSpectre GOSpectre;
typedef struct _GOPath GOPath;
typedef struct _GOString GOString;
typedef struct _GOStyle GOStyle;
@@ -119,6 +120,7 @@ G_END_DECLS
#include <goffice/utils/go-pixbuf.h>
#include <goffice/utils/go-svg.h>
#include <goffice/utils/go-emf.h>
+#include <goffice/utils/go-spectre.h>
#include <goffice/utils/go-libxml-extras.h>
#include <goffice/utils/go-line.h>
#include <goffice/utils/go-locale.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]