[PATCH] [ps] Enable image interpolation.

Chris Wilson chris at chris-wilson.co.uk
Thu Sep 4 18:53:51 PDT 2008


Set the /Interpolation value of the image dictionary to false if the filter
on the pattern is CAIRO_FILTER_NEAREST, and true otherwise.

See PostScript Language Reference, p301.
---
 src/cairo-ps-surface.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 28913c6..11ae7ff 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -1793,6 +1793,7 @@ _cairo_ps_surface_emit_base85_string (cairo_ps_surface_t    *surface,
 static cairo_status_t
 _cairo_ps_surface_emit_image (cairo_ps_surface_t    *surface,
 			      cairo_image_surface_t *image,
+			      cairo_filter_t	     filter,
 			      cairo_operator_t	     op)
 {
     cairo_status_t status;
@@ -1926,10 +1927,13 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t    *surface,
 				     "  /DataDict 8 dict def\n"
 				     "    DataDict begin\n"
 				     "    /ImageType 1 def\n"
+				     "    /Interpolate %s def\n"
 				     "    /Width %d def\n"
 				     "    /Height %d def\n"
 				     "    /BitsPerComponent 8 def\n"
 				     "    /Decode [ 0 1 0 1 0 1 ] def\n",
+				     filter != CAIRO_FILTER_NEAREST ?
+				     "true" : "false",
 				     image->width,
 				     image->height);
 
@@ -1952,6 +1956,7 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t    *surface,
 				     "  /MaskDict 8 dict def\n"
 				     "     MaskDict begin\n"
 				     "    /ImageType 1 def\n"
+				     "    /Interpolate %s def\n"
 				     "    /Width %d def\n"
 				     "    /Height %d def\n"
 				     "    /BitsPerComponent 1 def\n"
@@ -1961,6 +1966,8 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t    *surface,
 				     "end\n"
 				     "image\n",
 				     image->height,
+				     filter != CAIRO_FILTER_NEAREST ?
+				     "true" : "false",
 				     image->width,
 				     image->height,
 				     image->height);
@@ -1969,10 +1976,13 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t    *surface,
 				     "/DeviceRGB setcolorspace\n"
 				     "8 dict dup begin\n"
 				     "  /ImageType 1 def\n"
+				     "  /Interpolate %s def\n"
 				     "  /Width %d def\n"
 				     "  /Height %d def\n"
 				     "  /BitsPerComponent 8 def\n"
 				     "  /Decode [ 0 1 0 1 0 1 ] def\n",
+				     filter != CAIRO_FILTER_NEAREST ?
+				     "true" : "false",
 				     opaque_image->width,
 				     opaque_image->height);
 	if (surface->use_string_datasource) {
@@ -2178,7 +2188,10 @@ _cairo_ps_surface_emit_surface (cairo_ps_surface_t      *surface,
 	status = _cairo_ps_surface_emit_meta_surface (surface,
 						      meta_surface);
     } else {
-	status = _cairo_ps_surface_emit_image (surface, surface->image, op);
+	status = _cairo_ps_surface_emit_image (surface,
+					       surface->image,
+					       pattern->base.filter,
+					       op);
     }
 
     return status;
-- 
1.5.6.3


--=-ij3knZ5OH117LF4xX2xK--



More information about the cairo mailing list