[cairo-commit] 2 commits - src/cairo-pdf-surface.c src/cairo-ps-surface.c
Adrian Johnson
ajohnson at kemper.freedesktop.org
Tue Sep 6 07:21:45 PDT 2011
src/cairo-pdf-surface.c | 40 ++++++++++++++++++++++------------------
src/cairo-ps-surface.c | 2 +-
2 files changed, 23 insertions(+), 19 deletions(-)
New commits:
commit 7dca94fbc48b20280fa0a27cd46b00dba42aea97
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Tue Sep 6 23:50:46 2011 +0930
pdf: use interpolate in image smask
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index db639a1..3aa4f04 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1884,6 +1884,7 @@ static cairo_status_t
_cairo_pdf_surface_emit_smask (cairo_pdf_surface_t *surface,
cairo_image_surface_t *image,
cairo_bool_t stencil_mask,
+ const char *interpolate,
cairo_pdf_resource_t *stream_res)
{
cairo_status_t status = CAIRO_STATUS_SUCCESS;
@@ -1972,9 +1973,10 @@ _cairo_pdf_surface_emit_smask (cairo_pdf_surface_t *surface,
" /ImageMask true\n"
" /Width %d\n"
" /Height %d\n"
+ " /Interpolate %s\n"
" /BitsPerComponent 1\n"
" /Decode [1 0]\n",
- image->width, image->height);
+ image->width, image->height, interpolate);
} else {
stream_res->id = 0;
status = _cairo_pdf_surface_open_stream (surface,
@@ -1985,8 +1987,9 @@ _cairo_pdf_surface_emit_smask (cairo_pdf_surface_t *surface,
" /Width %d\n"
" /Height %d\n"
" /ColorSpace /DeviceGray\n"
+ " /Interpolate %s\n"
" /BitsPerComponent %d\n",
- image->width, image->height,
+ image->width, image->height, interpolate,
transparency == CAIRO_IMAGE_HAS_ALPHA ? 8 : 1);
}
if (unlikely (status))
@@ -2033,8 +2036,21 @@ _cairo_pdf_surface_emit_image (cairo_pdf_surface_t *surface,
image->format == CAIRO_FORMAT_A8 ||
image->format == CAIRO_FORMAT_A1);
+ switch (filter) {
+ case CAIRO_FILTER_GOOD:
+ case CAIRO_FILTER_BEST:
+ case CAIRO_FILTER_BILINEAR:
+ interpolate = "true";
+ break;
+ case CAIRO_FILTER_FAST:
+ case CAIRO_FILTER_NEAREST:
+ case CAIRO_FILTER_GAUSSIAN:
+ interpolate = "false";
+ break;
+ }
+
if (stencil_mask)
- return _cairo_pdf_surface_emit_smask (surface, image, stencil_mask, image_res);
+ return _cairo_pdf_surface_emit_smask (surface, image, stencil_mask, interpolate, image_res);
color = _cairo_image_analyze_color (image);
switch (color) {
@@ -2122,7 +2138,7 @@ _cairo_pdf_surface_emit_image (cairo_pdf_surface_t *surface,
if (image->format == CAIRO_FORMAT_ARGB32 ||
image->format == CAIRO_FORMAT_A8 ||
image->format == CAIRO_FORMAT_A1) {
- status = _cairo_pdf_surface_emit_smask (surface, image, FALSE, &smask);
+ status = _cairo_pdf_surface_emit_smask (surface, image, FALSE, interpolate, &smask);
if (unlikely (status))
goto CLEANUP_RGB;
@@ -2130,19 +2146,6 @@ _cairo_pdf_surface_emit_image (cairo_pdf_surface_t *surface,
need_smask = TRUE;
}
- switch (filter) {
- case CAIRO_FILTER_GOOD:
- case CAIRO_FILTER_BEST:
- case CAIRO_FILTER_BILINEAR:
- interpolate = "true";
- break;
- case CAIRO_FILTER_FAST:
- case CAIRO_FILTER_NEAREST:
- case CAIRO_FILTER_GAUSSIAN:
- interpolate = "false";
- break;
- }
-
#define IMAGE_DICTIONARY " /Type /XObject\n" \
" /Subtype /Image\n" \
" /Width %d\n" \
commit d47e05f8c222c0b7641af85d7ed6f50ee03297c4
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Tue Sep 6 23:41:12 2011 +0930
ps/pdf: fix the polarity of stencil masks
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 6d45422..db639a1 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1972,7 +1972,8 @@ _cairo_pdf_surface_emit_smask (cairo_pdf_surface_t *surface,
" /ImageMask true\n"
" /Width %d\n"
" /Height %d\n"
- " /BitsPerComponent 1\n",
+ " /BitsPerComponent 1\n"
+ " /Decode [1 0]\n",
image->width, image->height);
} else {
stream_res->id = 0;
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 9c1d299..fcfb2f1 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -2453,7 +2453,7 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t *surface,
ps_image->height,
interpolate,
color == CAIRO_IMAGE_IS_MONOCHROME ? 1 : 8,
- color == CAIRO_IMAGE_IS_COLOR ? "0 1 0 1 0 1" : "0 1");
+ stencil_mask ? "1 0" : color == CAIRO_IMAGE_IS_COLOR ? "0 1 0 1 0 1" : "0 1");
if (surface->use_string_datasource) {
_cairo_output_stream_printf (surface->stream,
" /DataSource {\n"
More information about the cairo-commit
mailing list