[cairo-commit] pycairo patch.cairo.h, NONE, 1.1 patch.cairo-image-surface.c, NONE, 1.1 INSTALL, 1.2, 1.3 configure.ac, 1.39, 1.40 ChangeLog, 1.187, 1.188

Steve Chaplin commit at pdx.freedesktop.org
Sun Oct 16 19:31:32 PDT 2005


Committed by: stevech1097

Update of /cvs/cairo/pycairo
In directory gabe:/tmp/cvs-serv7419

Modified Files:
	INSTALL configure.ac ChangeLog 
Added Files:
	patch.cairo.h patch.cairo-image-surface.c 
Log Message:
'SC'

--- NEW FILE: patch.cairo.h ---
Index: src/cairo.h
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo.h,v
retrieving revision 1.155
diff -u -u -r1.155 cairo.h
--- src/cairo.h	10 Oct 2005 19:45:15 -0000	1.155
+++ src/cairo.h	16 Oct 2005 08:08:15 -0000
@@ -1230,6 +1230,15 @@
 cairo_public int
 cairo_image_surface_get_height (cairo_surface_t *surface);
 
+cairo_public unsigned char *
+cairo_image_surface_get_data (cairo_surface_t *surface);
+
+cairo_public cairo_format_t
+cairo_image_surface_get_format (cairo_surface_t *surface);
+
+cairo_public int
+cairo_image_surface_get_stride (cairo_surface_t *surface);
+
 #if CAIRO_HAS_PNG_FUNCTIONS
 
 cairo_public cairo_surface_t *

--- NEW FILE: patch.cairo-image-surface.c ---
Index: src/cairo-image-surface.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-image-surface.c,v
retrieving revision 1.63
diff -u -u -r1.63 cairo-image-surface.c
--- src/cairo-image-surface.c	10 Oct 2005 19:45:15 -0000	1.63
+++ src/cairo-image-surface.c	16 Oct 2005 12:17:03 -0000
@@ -295,6 +295,45 @@
     return image_surface->height;
 }
 
+unsigned char *
+cairo_image_surface_get_data (cairo_surface_t *surface)
+{
+    cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
+
+    if (!_cairo_surface_is_image (surface)) {
+	_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+	return 0;
+    }
+
+    return image_surface->data;
+}
+
+cairo_format_t
+cairo_image_surface_get_format (cairo_surface_t *surface)
+{
+    cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
+
+    if (!_cairo_surface_is_image (surface)) {
+	_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+	return 0;
+    }
+
+    return image_surface->format;
+}
+
+int
+cairo_image_surface_get_stride (cairo_surface_t *surface)
+{
+    cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
+
+    if (!_cairo_surface_is_image (surface)) {
+	_cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+	return 0;
+    }
+
+    return image_surface->stride;
+}
+
 cairo_format_t
 _cairo_format_from_content (cairo_content_t content)
 {

Index: INSTALL
===================================================================
RCS file: /cvs/cairo/pycairo/INSTALL,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- INSTALL	11 Sep 2005 00:52:35 -0000	1.2
+++ INSTALL	17 Oct 2005 02:31:30 -0000	1.3
@@ -25,3 +25,20 @@
 To disable PyGTK support use
 
     $ ./configure --without-pygtk
+
+
+Enabling RGBA output (optional)
+--------------------
+An experimental patch is provided which enables RGBA output from a
+cairo.ImageSurface.
+It can be used, for example, to transfer cairo images into PIL.
+
+1) Apply the 'get_data' patch to cairo
+ $ cd cairo/src
+ $ patch < [path_to pycairo/patch.cairo-image-surface.c]
+ $ patch < [path_to pycairo/patch.cairo.h]
+
+2) Install cairo
+3) Install pycairo
+
+see test/to_rgba.py for example uses of 'surface.to_rgba()'

Index: configure.ac
===================================================================
RCS file: /cvs/cairo/pycairo/configure.ac,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- configure.ac	11 Oct 2005 06:54:32 -0000	1.39
+++ configure.ac	17 Oct 2005 02:31:30 -0000	1.40
@@ -96,6 +96,13 @@
 fi
 AM_CONDITIONAL(HAVE_LIBSVG_CAIRO, test x$have_libsvg_cairo = xyes)
 
+# cairo has cairo_image_surface_get_data() patch?
+save_LIBS="$LIBS"
+LIBS="$CAIRO_LIBS"
+AC_CHECK_LIB([cairo], [cairo_image_surface_get_data],
+  [AC_DEFINE(HAVE_GETDATA, [1], [Define to 1 if get_data patch is found])],
+  [])
+LIBS="$save_LIBS"
 
 # add gcc debugging options
 changequote(,)dnl

Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/pycairo/ChangeLog,v
retrieving revision 1.187
retrieving revision 1.188
diff -u -d -r1.187 -r1.188
--- ChangeLog	12 Oct 2005 03:13:47 -0000	1.187
+++ ChangeLog	17 Oct 2005 02:31:30 -0000	1.188
@@ -1,3 +1,17 @@
+2005-10-17  Steve Chaplin  <steve1097 at yahoo.com.au>
+
+	* INSTALL: add notes for installing get_data patch
+
+	* configure.ac: Add check for get_data patch
+
+	* patch.cairo.h
+	* patch.cairo-image-surface.c:
+	new files, patch cairo to enable 'surface.to_rgba()'
+
+	* test/to_rgba.py : new file, test surface.to_rgba()
+
+	* cairo/pycairo-surface.c (image_surface_to_rgba): new function
+
 2005-10-12  Steve Chaplin  <steve1097 at yahoo.com.au>
 
 	* cairo/pycairo-surface.c (surface_write_to_png): add support for



More information about the cairo-commit mailing list