diff options
Diffstat (limited to 'fitz/res_pixmap.c')
-rw-r--r-- | fitz/res_pixmap.c | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c index 7c6fbcc1..eb5d58ef 100644 --- a/fitz/res_pixmap.c +++ b/fitz/res_pixmap.c @@ -83,29 +83,29 @@ fz_new_pixmap(fz_context *ctx, fz_colorspace *colorspace, int w, int h) } fz_pixmap * -fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, fz_bbox r) +fz_new_pixmap_with_bbox(fz_context *ctx, fz_colorspace *colorspace, fz_rect rf) { - fz_pixmap *pixmap; - pixmap = fz_new_pixmap(ctx, colorspace, r.x1 - r.x0, r.y1 - r.y0); + fz_rect r = fz_round_rect(rf); + fz_pixmap *pixmap = fz_new_pixmap(ctx, colorspace, r.x1 - r.x0, r.y1 - r.y0); pixmap->x = r.x0; pixmap->y = r.y0; return pixmap; } fz_pixmap * -fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_bbox r, unsigned char *samples) +fz_new_pixmap_with_bbox_and_data(fz_context *ctx, fz_colorspace *colorspace, fz_rect rf, unsigned char *samples) { - fz_pixmap *pixmap; - pixmap = fz_new_pixmap_with_data(ctx, colorspace, r.x1 - r.x0, r.y1 - r.y0, samples); + fz_rect r = fz_round_rect(rf); + fz_pixmap *pixmap = fz_new_pixmap_with_data(ctx, colorspace, r.x1 - r.x0, r.y1 - r.y0, samples); pixmap->x = r.x0; pixmap->y = r.y0; return pixmap; } -fz_bbox +fz_rect fz_pixmap_bbox(fz_context *ctx, fz_pixmap *pix) { - fz_bbox bbox; + fz_rect bbox; bbox.x0 = pix->x; bbox.y0 = pix->y; bbox.x1 = pix->x + pix->w; @@ -113,10 +113,10 @@ fz_pixmap_bbox(fz_context *ctx, fz_pixmap *pix) return bbox; } -fz_bbox +fz_rect fz_pixmap_bbox_no_ctx(fz_pixmap *pix) { - fz_bbox bbox; + fz_rect bbox; bbox.x0 = pix->x; bbox.y0 = pix->y; bbox.x1 = pix->x + pix->w; @@ -166,14 +166,15 @@ fz_clear_pixmap_with_value(fz_context *ctx, fz_pixmap *pix, int value) } void -fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_bbox r) +fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_rect r) { const unsigned char *srcp; unsigned char *destp; int x, y, w, destspan, srcspan; - r = fz_intersect_bbox(r, fz_pixmap_bbox(ctx, dest)); - r = fz_intersect_bbox(r, fz_pixmap_bbox(ctx, src)); + r = fz_round_rect(r); + r = fz_intersect_rect(r, fz_pixmap_bbox(ctx, dest)); + r = fz_intersect_rect(r, fz_pixmap_bbox(ctx, src)); w = r.x1 - r.x0; y = r.y1 - r.y0; if (w <= 0 || y <= 0) @@ -266,12 +267,13 @@ fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_bbox r) } void -fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *dest, int value, fz_bbox r) +fz_clear_pixmap_rect_with_value(fz_context *ctx, fz_pixmap *dest, int value, fz_rect r) { unsigned char *destp; int x, y, w, k, destspan; - r = fz_intersect_bbox(r, fz_pixmap_bbox(ctx, dest)); + r = fz_round_rect(r); + r = fz_intersect_rect(r, fz_pixmap_bbox(ctx, dest)); w = r.x1 - r.x0; y = r.y1 - r.y0; if (w <= 0 || y <= 0) @@ -382,15 +384,17 @@ fz_invert_pixmap(fz_context *ctx, fz_pixmap *pix) } } -void fz_invert_pixmap_rect(fz_pixmap *image, fz_bbox rect) +void fz_invert_pixmap_rect(fz_pixmap *image, fz_rect r) { unsigned char *p; + int x0, x1, y0, y1; int x, y, n; - int x0 = fz_clampi(rect.x0 - image->x, 0, image->w - 1); - int x1 = fz_clampi(rect.x1 - image->x, 0, image->w - 1); - int y0 = fz_clampi(rect.y0 - image->y, 0, image->h - 1); - int y1 = fz_clampi(rect.y1 - image->y, 0, image->h - 1); + r = fz_round_rect(r); + x0 = fz_clampi(r.x0 - image->x, 0, image->w - 1); + x1 = fz_clampi(r.x1 - image->x, 0, image->w - 1); + y0 = fz_clampi(r.y0 - image->y, 0, image->h - 1); + y1 = fz_clampi(r.y1 - image->y, 0, image->h - 1); for (y = y0; y < y1; y++) { |