summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2012-04-23 13:07:18 +0930
committerAdrian Johnson <ajohnson@redneon.com>2012-04-23 13:21:52 +0930
commit33f9e433eef13a2b39a8213c6997399f3a5896a8 (patch)
tree9f8666e9a7a7ef03bbddbcbf18bb6e2eb0457741
parentc0b523eb652b2c4ba41cb27132d46ad9211b5df4 (diff)
pdf: support all image types
If the image is not rgb24/argb32/a8/a1, create a new image with the same CAIRO_CONTENT and paint image to the new image.
-rw-r--r--src/cairo-pdf-surface.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index a0a20e8f3..3b65167e7 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -2323,7 +2323,7 @@ _cairo_pdf_surface_emit_smask (cairo_pdf_surface_t *surface,
* can be used to reference the data in image_ret. */
static cairo_status_t
_cairo_pdf_surface_emit_image (cairo_pdf_surface_t *surface,
- cairo_image_surface_t *image,
+ cairo_image_surface_t *image_surf,
cairo_pdf_resource_t *image_res,
cairo_filter_t filter,
cairo_bool_t stencil_mask)
@@ -2337,16 +2337,34 @@ _cairo_pdf_surface_emit_image (cairo_pdf_surface_t *surface,
cairo_bool_t need_smask;
const char *interpolate = "true";
cairo_image_color_t color;
+ cairo_image_surface_t *image;
- /* These are the only image formats we currently support, (which
- * makes things a lot simpler here). This is enforced through
- * _cairo_pdf_surface_analyze_operation which only accept source surfaces of
- * CONTENT_COLOR or CONTENT_COLOR_ALPHA.
- */
- assert (image->format == CAIRO_FORMAT_RGB24 ||
- image->format == CAIRO_FORMAT_ARGB32 ||
- image->format == CAIRO_FORMAT_A8 ||
- image->format == CAIRO_FORMAT_A1);
+ image = image_surf;
+ if (image->format != CAIRO_FORMAT_RGB24 &&
+ image->format != CAIRO_FORMAT_ARGB32 &&
+ image->format != CAIRO_FORMAT_A8 &&
+ image->format != CAIRO_FORMAT_A1)
+ {
+ cairo_surface_t *surf;
+ cairo_surface_pattern_t pattern;
+
+ surf = _cairo_image_surface_create_with_content (cairo_surface_get_content (&image_surf->base),
+ image_surf->width,
+ image_surf->height);
+ image = (cairo_image_surface_t *) surf;
+ if (surf->status) {
+ status = surf->status;
+ goto CLEANUP;
+ }
+
+ _cairo_pattern_init_for_surface (&pattern, &image_surf->base);
+ status = _cairo_surface_paint (surf,
+ CAIRO_OPERATOR_SOURCE, &pattern.base,
+ NULL);
+ _cairo_pattern_fini (&pattern.base);
+ if (unlikely (status))
+ goto CLEANUP;
+ }
switch (filter) {
case CAIRO_FILTER_GOOD:
@@ -2497,6 +2515,9 @@ _cairo_pdf_surface_emit_image (cairo_pdf_surface_t *surface,
CLEANUP_RGB:
free (data);
CLEANUP:
+ if (image != image_surf)
+ cairo_surface_destroy (&image->base);
+
return status;
}