diff options
Diffstat (limited to 'fitz/res_halftone.c')
-rw-r--r-- | fitz/res_halftone.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/fitz/res_halftone.c b/fitz/res_halftone.c index 7258ad01..daad6e37 100644 --- a/fitz/res_halftone.c +++ b/fitz/res_halftone.c @@ -1,4 +1,4 @@ -#include "fitz.h" +#include "fitz-internal.h" fz_halftone * fz_new_halftone(fz_context *ctx, int comps) @@ -56,7 +56,7 @@ static unsigned char mono_ht[] = 0xF2, 0x72, 0xD2, 0x52, 0xFA, 0x7A, 0xDA, 0x5A, 0xF0, 0x70, 0xD0, 0x50, 0xF8, 0x78, 0xD8, 0x58 }; -fz_halftone *fz_get_default_halftone(fz_context *ctx, int num_comps) +fz_halftone *fz_default_halftone(fz_context *ctx, int num_comps) { fz_halftone *ht = fz_new_halftone(ctx, num_comps); assert(num_comps == 1); /* Only support 1 component for now */ @@ -162,13 +162,18 @@ fz_bitmap *fz_halftone_pixmap(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht) fz_bitmap *out; unsigned char *ht_line, *o, *p; int w, h, x, y, n, pstride, ostride; + fz_halftone *ht_orig = ht; - if (!pix || !ht) + if (!pix) return NULL; assert(pix->n == 2); /* Mono + Alpha */ n = pix->n-1; /* Remove alpha */ + if (ht == NULL) + { + ht = fz_default_halftone(ctx, n); + } ht_line = fz_malloc(ctx, pix->w * n); out = fz_new_bitmap(ctx, pix->w, pix->h, n); o = out->samples; @@ -187,5 +192,7 @@ fz_bitmap *fz_halftone_pixmap(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht) o += ostride; p += pstride; } + if (!ht_orig) + fz_drop_halftone(ctx, ht); return out; } |