diff options
author | Adrian Johnson <ajohnson@redneon.com> | 2017-10-22 08:45:45 +1030 |
---|---|---|
committer | Adrian Johnson <ajohnson@redneon.com> | 2017-10-22 08:59:58 +1030 |
commit | 87dfd0c16f4fa798c1f72612a2e070fca8547ad2 (patch) | |
tree | a676a02d95a889fe27e314875eac2537ef29cbb2 /src/cairo-ps-surface.c | |
parent | e1a02b180d804887980c111c1f9780bed44b96a6 (diff) | |
download | cairo-87dfd0c16f4fa798c1f72612a2e070fca8547ad2.tar.gz |
Allow mime image to be different size to cairo image
Previously it was assumed the mime image size is the same as the cairo
image surface size. When using the 1 bpp formats (CCITT, JBIG2),
creating a cairo image of the same size will have very large memory
requirements and in some case may exceed the pixman image size
limits. In these cases it is useful to allow the mime image to have a
different resolution to the cairo image and in the PDF/PS output scale
the mime image to be the same physical size as the cairo image.
In PDF, this is easy as all PDF images are scaled to 1x1 unit and the
CTM is used to scale the image to the required size. The PS surface
has been changed to also scale images to 1x1 and use the CTM to get
the required size.
Diffstat (limited to 'src/cairo-ps-surface.c')
-rw-r--r-- | src/cairo-ps-surface.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index 62b19e4af..905ee2c84 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -2754,7 +2754,7 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t *surface, } _cairo_output_stream_printf (surface->stream, - " /ImageMatrix [ 1 0 0 -1 0 %d ] def\n" + " /ImageMatrix [ %d 0 0 %d 0 %d ] def\n" " end\n" " /MaskDict 8 dict def\n" " MaskDict begin\n" @@ -2764,14 +2764,18 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t *surface, " /Interpolate %s def\n" " /BitsPerComponent 1 def\n" " /Decode [ 1 0 ] def\n" - " /ImageMatrix [ 1 0 0 -1 0 %d ] def\n" + " /ImageMatrix [ %d 0 0 %d 0 %d ] def\n" " end\n" "end\n" "image\n", + ps_image->width, + -ps_image->height, ps_image->height, ps_image->width, ps_image->height, interpolate, + ps_image->width, + -ps_image->height, ps_image->height); } else { if (!stencil_mask) { @@ -2808,9 +2812,11 @@ _cairo_ps_surface_emit_image (cairo_ps_surface_t *surface, } _cairo_output_stream_printf (surface->stream, - " /ImageMatrix [ 1 0 0 -1 0 %d ] def\n" + " /ImageMatrix [ %d 0 0 %d 0 %d ] def\n" "end\n" "%s%s\n", + ps_image->width, + -ps_image->height, ps_image->height, surface->use_string_datasource ? "" : "cairo_", stencil_mask ? "imagemask" : "image"); @@ -2936,9 +2942,11 @@ _cairo_ps_surface_emit_jpeg_image (cairo_ps_surface_t *surface, } _cairo_output_stream_printf (surface->stream, - " /ImageMatrix [ 1 0 0 -1 0 %d ] def\n" + " /ImageMatrix [ %d 0 0 %d 0 %d ] def\n" "end\n" "%simage\n", + info.width, + -info.height, info.height, surface->use_string_datasource ? "" : "cairo_"); @@ -3077,9 +3085,11 @@ _cairo_ps_surface_emit_ccitt_image (cairo_ps_surface_t *surface, " >> /CCITTFaxDecode filter\n"); _cairo_output_stream_printf (surface->stream, - " /ImageMatrix [ 1 0 0 -1 0 %d ]\n" + " /ImageMatrix [ %d 0 0 %d 0 %d ]\n" ">>\n" "%s%s\n", + ccitt_params.columns, + -ccitt_params.rows, ccitt_params.rows, surface->use_string_datasource ? "" : "cairo_", stencil_mask ? "imagemask" : "image"); @@ -3407,6 +3417,7 @@ _cairo_ps_surface_paint_surface (cairo_ps_surface_t *surface, { cairo_matrix_translate (&ps_p2d, 0.0, src_surface_extents.height); cairo_matrix_scale (&ps_p2d, 1.0, -1.0); + cairo_matrix_scale (&ps_p2d, src_surface_extents.width, src_surface_extents.height); } if (! _cairo_matrix_is_identity (&ps_p2d)) { @@ -3545,6 +3556,14 @@ _cairo_ps_surface_emit_surface_pattern (cairo_ps_surface_t *surface, pattern_extents.x, pattern_extents.y, pattern_extents.width, pattern_extents.height); + + if (((cairo_surface_pattern_t *)pattern)->surface->type != CAIRO_SURFACE_TYPE_RECORDING) + { + _cairo_output_stream_printf (surface->stream, + "[ %d 0 0 %d 0 0 ] concat\n", + pattern_extents.width, pattern_extents.height); + } + old_use_string_datasource = surface->use_string_datasource; surface->use_string_datasource = TRUE; if (op == CAIRO_OPERATOR_SOURCE) { |