diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2013-02-13 13:55:05 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2013-02-13 13:55:05 +0100 |
commit | de1ccbf74a1061af9b4462eaef84510d6030775d (patch) | |
tree | 0b65c6cc902a95fb0e34c451ebca30f86376f9ea /doc/example.c | |
parent | cc4e2c8cb5e0e12ac55c3aff775b710a3fecbcdc (diff) | |
download | mupdf-de1ccbf74a1061af9b4462eaef84510d6030775d.tar.xz |
Update doc/example.c for passing rect/matrix by reference.
Diffstat (limited to 'doc/example.c')
-rw-r--r-- | doc/example.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/doc/example.c b/doc/example.c index d1e4798f..d60c7cd6 100644 --- a/doc/example.c +++ b/doc/example.c @@ -35,14 +35,16 @@ render(char *filename, int pagenumber, int zoom, int rotation) // contains the scale and rotation. Convert zoom percentage to a // scaling factor. Without scaling the resolution is 72 dpi. - fz_matrix transform = fz_scale(zoom / 100.0f, zoom / 100.0f); - transform = fz_concat(transform, fz_rotate(rotation)); + fz_matrix transform; + fz_rotate(&transform, rotation); + fz_pre_scale(&transform, zoom / 100.0f, zoom / 100.0f); // Take the page bounds and transform them by the same matrix that // we will use to render the page. - fz_rect bounds = fz_bound_page(doc, page); - bounds = fz_transform_rect(transform, rect); + fz_rect bounds; + fz_bound_page(doc, page, &bounds); + fz_transform_rect(&bounds, &transform); // Create a blank pixmap to hold the result of rendering. The // pixmap bounds used here are the same as the transformed page @@ -50,8 +52,9 @@ render(char *filename, int pagenumber, int zoom, int rotation) // space has the origin at the top left corner and the x axis // extends to the right and the y axis extends down. - fz_irect bbox = fz_round_rect(bounds); - fz_pixmap *pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb, bbox); + fz_irect bbox; + fz_round_rect(&bbox, &bounds); + fz_pixmap *pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb, &bbox); fz_clear_pixmap_with_value(ctx, pix, 0xff); // A page consists of a series of objects (text, line art, images, @@ -73,7 +76,7 @@ render(char *filename, int pagenumber, int zoom, int rotation) // Run the page with the transform. fz_device *dev = fz_new_draw_device(ctx, pix); - fz_run_page(doc, page, dev, transform, NULL); + fz_run_page(doc, page, dev, &transform, NULL); fz_free_device(dev); // Save the pixmap to a file. |