From e6b8d0c6b1809e012da290202108f1ac76153774 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Tue, 10 Apr 2012 13:42:40 +0100 Subject: Add fz_new_draw_device_with_bbox function Restricts rendering to a sub rectangle of the supplied bbox. --- draw/draw_device.c | 17 +++++++++++++++++ fitz/fitz.h | 14 ++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/draw/draw_device.c b/draw/draw_device.c index 2ee0de77..3df440ef 100644 --- a/draw/draw_device.c +++ b/draw/draw_device.c @@ -1652,6 +1652,23 @@ fz_new_draw_device(fz_context *ctx, fz_pixmap *dest) return dev; } +fz_device * +fz_new_draw_device_with_bbox(fz_context *ctx, fz_pixmap *dest, fz_bbox clip) +{ + fz_device *dev = fz_new_draw_device(ctx, dest); + fz_draw_device *ddev = dev->user; + + if (clip.x0 > ddev->stack[0].scissor.x0) + ddev->stack[0].scissor.x0 = clip.x0; + if (clip.x1 < ddev->stack[0].scissor.x1) + ddev->stack[0].scissor.x1 = clip.x1; + if (clip.y0 > ddev->stack[0].scissor.y0) + ddev->stack[0].scissor.y0 = clip.y0; + if (clip.y1 < ddev->stack[0].scissor.y1) + ddev->stack[0].scissor.y1 = clip.y1; + return dev; +} + fz_device * fz_new_draw_device_type3(fz_context *ctx, fz_pixmap *dest) { diff --git a/fitz/fitz.h b/fitz/fitz.h index 732cb9d2..1355c740 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -1517,6 +1517,20 @@ fz_device *fz_new_bbox_device(fz_context *ctx, fz_bbox *bboxp); */ fz_device *fz_new_draw_device(fz_context *ctx, fz_pixmap *dest); +/* + fz_new_draw_device_with_bbox: Create a device to draw on a pixmap. + + dest: Target pixmap for the draw device. See fz_new_pixmap* + for how to obtain a pixmap. The pixmap is not cleared by the + draw device, see fz_clear_pixmap* for how to clear it prior to + calling fz_new_draw_device. Free the device by calling + fz_free_device. + + clip: Bounding box to restrict any marking operations of the + draw device. +*/ +fz_device *fz_new_draw_device_with_bbox(fz_context *ctx, fz_pixmap *dest, fz_bbox clip); + /* Text extraction device: Used for searching, format conversion etc. -- cgit v1.2.3