diff options
-rw-r--r-- | apps/mupdfdraw.c | 10 | ||||
-rw-r--r-- | apps/muxpsdraw.c | 4 | ||||
-rw-r--r-- | apps/pdfapp.c | 2 | ||||
-rw-r--r-- | draw/draw_device.c | 67 | ||||
-rw-r--r-- | draw/draw_mesh.c | 2 | ||||
-rw-r--r-- | fitz/fitz.h | 29 | ||||
-rw-r--r-- | fitz/image_jpeg.c | 2 | ||||
-rw-r--r-- | fitz/image_jpx.c | 2 | ||||
-rw-r--r-- | fitz/image_png.c | 2 | ||||
-rw-r--r-- | fitz/image_tiff.c | 2 | ||||
-rw-r--r-- | fitz/res_bitmap.c | 9 | ||||
-rw-r--r-- | fitz/res_font.c | 2 | ||||
-rw-r--r-- | fitz/res_halftone.c | 5 | ||||
-rw-r--r-- | fitz/res_pixmap.c | 18 | ||||
-rw-r--r-- | fitz/stm_buffer.c | 5 | ||||
-rw-r--r-- | fitz/stm_open.c | 2 | ||||
-rw-r--r-- | pdf/pdf_image.c | 2 |
17 files changed, 85 insertions, 80 deletions
diff --git a/apps/mupdfdraw.c b/apps/mupdfdraw.c index 0ab89449..e12a21b1 100644 --- a/apps/mupdfdraw.c +++ b/apps/mupdfdraw.c @@ -212,9 +212,9 @@ static void drawpage(pdf_document *doc, int pagenum) pix = fz_new_pixmap_with_rect(ctx, colorspace, bbox); if (savealpha) - fz_clear_pixmap(pix); + fz_clear_pixmap(ctx, pix); else - fz_clear_pixmap_with_color(pix, 255); + fz_clear_pixmap_with_color(ctx, pix, 255); dev = fz_new_draw_device(ctx, pix); if (list) @@ -225,12 +225,12 @@ static void drawpage(pdf_document *doc, int pagenum) dev = NULL; if (invert) - fz_invert_pixmap(pix); + fz_invert_pixmap(ctx, pix); if (gamma_value != 1) - fz_gamma_pixmap(pix, gamma_value); + fz_gamma_pixmap(ctx, pix, gamma_value); if (savealpha) - fz_unmultiply_pixmap(pix); + fz_unmultiply_pixmap(ctx, pix); if (output) { diff --git a/apps/muxpsdraw.c b/apps/muxpsdraw.c index 53956478..06270b71 100644 --- a/apps/muxpsdraw.c +++ b/apps/muxpsdraw.c @@ -147,9 +147,9 @@ static void drawpage(xps_document *doc, int pagenum) pix = fz_new_pixmap_with_rect(doc->ctx, colorspace, bbox); if (savealpha) - fz_clear_pixmap(pix); + fz_clear_pixmap(doc->ctx, pix); else - fz_clear_pixmap_with_color(pix, 255); + fz_clear_pixmap_with_color(doc->ctx, pix, 255); dev = fz_new_draw_device(doc->ctx, pix); if (list) diff --git a/apps/pdfapp.c b/apps/pdfapp.c index cd4b0747..846e6eb6 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -313,7 +313,7 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai colorspace = fz_device_rgb; #endif app->image = fz_new_pixmap_with_rect(app->ctx, colorspace, bbox); - fz_clear_pixmap_with_color(app->image, 255); + fz_clear_pixmap_with_color(app->ctx, app->image, 255); idev = fz_new_draw_device(app->ctx, app->image); fz_execute_display_list(app->page_list, idev, ctm, bbox, NULL); fz_free_device(idev); diff --git a/draw/draw_device.c b/draw/draw_device.c index 03e5d268..fa97ad1e 100644 --- a/draw/draw_device.c +++ b/draw/draw_device.c @@ -110,6 +110,7 @@ push_stack(fz_draw_device *dev) static fz_draw_state * fz_knockout_begin(fz_draw_device *dev) { + fz_context *ctx = dev->ctx; fz_bbox bbox; fz_pixmap *dest, *shape; fz_draw_state *state = &dev->stack[dev->top]; @@ -126,7 +127,7 @@ fz_knockout_begin(fz_draw_device *dev) if (isolated) { - fz_clear_pixmap(dest); + fz_clear_pixmap(ctx, dest); } else { @@ -140,9 +141,9 @@ fz_knockout_begin(fz_draw_device *dev) break; } if (prev) - fz_copy_pixmap_rect(dest, prev, bbox); + fz_copy_pixmap_rect(ctx, dest, prev, bbox); else - fz_clear_pixmap(dest); + fz_clear_pixmap(ctx, dest); } if (state->blendmode == 0 && isolated) @@ -154,7 +155,7 @@ fz_knockout_begin(fz_draw_device *dev) else { shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox); - fz_clear_pixmap(shape); + fz_clear_pixmap(dev->ctx, shape); } #ifdef DUMP_GROUP_BLENDS dump_spaces(dev->top-1, "Knockout begin\n"); @@ -354,13 +355,13 @@ fz_draw_clip_path(fz_device *devp, fz_path *path, fz_rect *rect, int even_odd, f } state[1].mask = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox); - fz_clear_pixmap(state[1].mask); + fz_clear_pixmap(dev->ctx, state[1].mask); state[1].dest = fz_new_pixmap_with_rect(dev->ctx, model, bbox); - fz_clear_pixmap(state[1].dest); + fz_clear_pixmap(dev->ctx, state[1].dest); if (state[1].shape) { state[1].shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox); - fz_clear_pixmap(state[1].shape); + fz_clear_pixmap(dev->ctx, state[1].shape); } fz_scan_convert(dev->gel, even_odd, bbox, state[1].mask, NULL); @@ -399,13 +400,13 @@ fz_draw_clip_stroke_path(fz_device *devp, fz_path *path, fz_rect *rect, fz_strok bbox = fz_intersect_bbox(bbox, fz_round_rect(*rect)); state[1].mask = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox); - fz_clear_pixmap(state[1].mask); + fz_clear_pixmap(dev->ctx, state[1].mask); state[1].dest = fz_new_pixmap_with_rect(dev->ctx, model, bbox); - fz_clear_pixmap(state[1].dest); + fz_clear_pixmap(dev->ctx, state[1].dest); if (state->shape) { state[1].shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox); - fz_clear_pixmap(state[1].shape); + fz_clear_pixmap(dev->ctx, state[1].shape); } if (!fz_is_empty_rect(bbox)) @@ -600,13 +601,13 @@ fz_draw_clip_text(fz_device *devp, fz_text *text, fz_matrix ctm, int accumulate) if (accumulate == 0 || accumulate == 1) { mask = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox); - fz_clear_pixmap(mask); + fz_clear_pixmap(dev->ctx, mask); dest = fz_new_pixmap_with_rect(dev->ctx, model, bbox); - fz_clear_pixmap(dest); + fz_clear_pixmap(dev->ctx, dest); if (state->shape) { shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox); - fz_clear_pixmap(shape); + fz_clear_pixmap(dev->ctx, shape); } else shape = NULL; @@ -673,13 +674,13 @@ fz_draw_clip_stroke_text(fz_device *devp, fz_text *text, fz_stroke_state *stroke bbox = fz_intersect_bbox(bbox, state->scissor); mask = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox); - fz_clear_pixmap(mask); + fz_clear_pixmap(dev->ctx, mask); dest = fz_new_pixmap_with_rect(dev->ctx, model, bbox); - fz_clear_pixmap(dest); + fz_clear_pixmap(dev->ctx, dest); if (state->shape) { shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox); - fz_clear_pixmap(shape); + fz_clear_pixmap(dev->ctx, shape); } else shape = state->shape; @@ -762,11 +763,11 @@ fz_draw_fill_shade(fz_device *devp, fz_shade *shade, fz_matrix ctm, float alpha) if (alpha < 1) { dest = fz_new_pixmap_with_rect(dev->ctx, state->dest->colorspace, bbox); - fz_clear_pixmap(dest); + fz_clear_pixmap(dev->ctx, dest); if (shape) { shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox); - fz_clear_pixmap(shape); + fz_clear_pixmap(dev->ctx, shape); } } @@ -804,7 +805,7 @@ fz_draw_fill_shade(fz_device *devp, fz_shade *shade, fz_matrix ctm, float alpha) fz_paint_shade(dev->ctx, shade, ctm, dest, bbox); if (shape) - fz_clear_pixmap_rect_with_color(shape, 255, bbox); + fz_clear_pixmap_rect_with_color(dev->ctx, shape, 255, bbox); if (alpha < 1) { @@ -1068,15 +1069,15 @@ fz_draw_clip_image_mask(fz_device *devp, fz_pixmap *image, fz_rect *rect, fz_mat bbox = fz_intersect_bbox(bbox, fz_round_rect(*rect)); mask = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox); - fz_clear_pixmap(mask); + fz_clear_pixmap(dev->ctx, mask); fz_try(ctx) { dest = fz_new_pixmap_with_rect(dev->ctx, model, bbox); - fz_clear_pixmap(dest); + fz_clear_pixmap(dev->ctx, dest); if (state->shape) { shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox); - fz_clear_pixmap(shape); + fz_clear_pixmap(dev->ctx, shape); } dx = sqrtf(ctm.a * ctm.a + ctm.b * ctm.b); @@ -1198,15 +1199,15 @@ fz_draw_begin_mask(fz_device *devp, fz_rect rect, int luminosity, fz_colorspace if (!colorspace) colorspace = fz_device_gray; fz_convert_color(dev->ctx, colorspace, colorfv, fz_device_gray, &bc); - fz_clear_pixmap_with_color(dest, bc * 255); + fz_clear_pixmap_with_color(dev->ctx, dest, bc * 255); if (shape) - fz_clear_pixmap_with_color(shape, 255); + fz_clear_pixmap_with_color(dev->ctx, shape, 255); } else { - fz_clear_pixmap(dest); + fz_clear_pixmap(dev->ctx, dest); if (shape) - fz_clear_pixmap(shape); + fz_clear_pixmap(dev->ctx, shape); } #ifdef DUMP_GROUP_BLENDS @@ -1255,7 +1256,7 @@ fz_draw_end_mask(fz_device *devp) /* create new dest scratch buffer */ bbox = fz_bound_pixmap(temp); dest = fz_new_pixmap_with_rect(dev->ctx, state->dest->colorspace, bbox); - fz_clear_pixmap(dest); + fz_clear_pixmap(dev->ctx, dest); /* push soft mask as clip mask */ state[1].mask = temp; @@ -1266,7 +1267,7 @@ fz_draw_end_mask(fz_device *devp) if (state[0].shape) { state[1].shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox); - fz_clear_pixmap(state[1].shape); + fz_clear_pixmap(dev->ctx, state[1].shape); } state[1].scissor = bbox; } @@ -1296,11 +1297,11 @@ fz_draw_begin_group(fz_device *devp, fz_rect rect, int isolated, int knockout, i if (isolated) { - fz_clear_pixmap(dest); + fz_clear_pixmap(dev->ctx, dest); } else { - fz_copy_pixmap_rect(dest, state[0].dest, bbox); + fz_copy_pixmap_rect(dev->ctx, dest, state[0].dest, bbox); } if (blendmode == 0 && alpha == 1.0 && isolated) @@ -1314,7 +1315,7 @@ fz_draw_begin_group(fz_device *devp, fz_rect rect, int isolated, int knockout, i fz_try(ctx) { shape = fz_new_pixmap_with_rect(ctx, NULL, bbox); - fz_clear_pixmap(shape); + fz_clear_pixmap(dev->ctx, shape); } fz_catch(ctx) { @@ -1421,7 +1422,7 @@ fz_draw_begin_tile(fz_device *devp, fz_rect area, fz_rect view, float xstep, flo * bbox.y0 > state->dest->y || bbox.y1 < state->dest->y + state->dest->h); */ dest = fz_new_pixmap_with_rect(dev->ctx, model, bbox); - fz_clear_pixmap(dest); + fz_clear_pixmap(ctx, dest); shape = state[0].shape; if (shape) { @@ -1429,7 +1430,7 @@ fz_draw_begin_tile(fz_device *devp, fz_rect area, fz_rect view, float xstep, flo fz_try(ctx) { shape = fz_new_pixmap_with_rect(dev->ctx, NULL, bbox); - fz_clear_pixmap(shape); + fz_clear_pixmap(ctx, shape); } fz_catch(ctx) { diff --git a/draw/draw_mesh.c b/draw/draw_mesh.c index 06c1f55a..79bac732 100644 --- a/draw/draw_mesh.c +++ b/draw/draw_mesh.c @@ -546,7 +546,7 @@ fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, } conv = fz_new_pixmap_with_rect(ctx, dest->colorspace, bbox); temp = fz_new_pixmap_with_rect(ctx, fz_device_gray, bbox); - fz_clear_pixmap(temp); + fz_clear_pixmap(ctx, temp); } else { diff --git a/fitz/fitz.h b/fitz/fitz.h index 65fd47de..997e5658 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -720,7 +720,7 @@ struct fz_buffer_s }; fz_buffer *fz_new_buffer(fz_context *ctx, int size); -fz_buffer *fz_keep_buffer(fz_buffer *buf); +fz_buffer *fz_keep_buffer(fz_context *ctx, fz_buffer *buf); void fz_drop_buffer(fz_context *ctx, fz_buffer *buf); void fz_resize_buffer(fz_context *ctx, fz_buffer *buf, int size); @@ -936,6 +936,8 @@ struct fz_pixmap_s int free_samples; }; +fz_bbox fz_bound_pixmap(fz_pixmap *pix); + fz_pixmap *fz_new_pixmap_with_data(fz_context *ctx, fz_colorspace *colorspace, int w, int h, unsigned char *samples); fz_pixmap *fz_new_pixmap_with_rect(fz_context *ctx, fz_colorspace *, fz_bbox bbox); fz_pixmap *fz_new_pixmap_with_rect_and_data(fz_context *ctx, fz_colorspace *, fz_bbox bbox, unsigned char *samples); @@ -943,17 +945,16 @@ fz_pixmap *fz_new_pixmap(fz_context *ctx, fz_colorspace *, int w, int h); fz_pixmap *fz_keep_pixmap(fz_context *ctx, fz_pixmap *pix); void fz_drop_pixmap(fz_context *ctx, fz_pixmap *pix); void fz_free_pixmap_imp(fz_context *ctx, fz_storable *pix); -void fz_clear_pixmap(fz_pixmap *pix); -void fz_clear_pixmap_with_color(fz_pixmap *pix, int value); -void fz_clear_pixmap_rect_with_color(fz_pixmap *pix, int value, fz_bbox r); -void fz_copy_pixmap_rect(fz_pixmap *dest, fz_pixmap *src, fz_bbox r); -void fz_premultiply_pixmap(fz_pixmap *pix); -void fz_unmultiply_pixmap(fz_pixmap *pix); +void fz_clear_pixmap(fz_context *ctx, fz_pixmap *pix); +void fz_clear_pixmap_with_color(fz_context *ctx, fz_pixmap *pix, int value); +void fz_clear_pixmap_rect_with_color(fz_context *ctx, fz_pixmap *pix, int value, fz_bbox r); +void fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_bbox r); +void fz_premultiply_pixmap(fz_context *ctx, fz_pixmap *pix); +void fz_unmultiply_pixmap(fz_context *ctx, fz_pixmap *pix); fz_pixmap *fz_alpha_from_gray(fz_context *ctx, fz_pixmap *gray, int luminosity); -fz_bbox fz_bound_pixmap(fz_pixmap *pix); -void fz_invert_pixmap(fz_pixmap *pix); -void fz_gamma_pixmap(fz_pixmap *pix, float gamma); -unsigned int fz_pixmap_size(fz_pixmap *pix); +void fz_invert_pixmap(fz_context *ctx, fz_pixmap *pix); +void fz_gamma_pixmap(fz_context *ctx, fz_pixmap *pix, float gamma); +unsigned int fz_pixmap_size(fz_context *ctx, fz_pixmap *pix); fz_pixmap *fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, fz_bbox *clip); @@ -982,8 +983,8 @@ struct fz_bitmap_s }; fz_bitmap *fz_new_bitmap(fz_context *ctx, int w, int h, int n); -fz_bitmap *fz_keep_bitmap(fz_bitmap *bit); -void fz_clear_bitmap(fz_bitmap *bit); +fz_bitmap *fz_keep_bitmap(fz_context *ctx, fz_bitmap *bit); +void fz_clear_bitmap(fz_context *ctx, fz_bitmap *bit); void fz_drop_bitmap(fz_context *ctx, fz_bitmap *bit); void fz_write_pbm(fz_context *ctx, fz_bitmap *bitmap, char *filename); @@ -1004,7 +1005,7 @@ struct fz_halftone_s fz_halftone *fz_new_halftone(fz_context *ctx, int num_comps); fz_halftone *fz_get_default_halftone(fz_context *ctx, int num_comps); -fz_halftone *fz_keep_halftone(fz_halftone *half); +fz_halftone *fz_keep_halftone(fz_context *ctx, fz_halftone *half); void fz_drop_halftone(fz_context *ctx, fz_halftone *half); fz_bitmap *fz_halftone_pixmap(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht); diff --git a/fitz/image_jpeg.c b/fitz/image_jpeg.c index f2688d46..f53b6124 100644 --- a/fitz/image_jpeg.c +++ b/fitz/image_jpeg.c @@ -115,7 +115,7 @@ fz_load_jpeg(fz_context *ctx, unsigned char *rbuf, int rlen) image->yres = cinfo.Y_density * 254 / 100; } - fz_clear_pixmap(image); + fz_clear_pixmap(ctx, image); row[0] = fz_malloc(ctx, cinfo.output_components * cinfo.output_width); dp = image->samples; diff --git a/fitz/image_jpx.c b/fitz/image_jpx.c index b49b2625..4d76b4e8 100644 --- a/fitz/image_jpx.c +++ b/fitz/image_jpx.c @@ -148,7 +148,7 @@ fz_load_jpx(fz_context *ctx, unsigned char *data, int size, fz_colorspace *defcs fz_drop_pixmap(ctx, img); img = tmp; } - fz_premultiply_pixmap(img); + fz_premultiply_pixmap(ctx, img); } opj_image_destroy(jpx); diff --git a/fitz/image_png.c b/fitz/image_png.c index feaadb52..b3fe39cc 100644 --- a/fitz/image_png.c +++ b/fitz/image_png.c @@ -556,7 +556,7 @@ fz_load_png(fz_context *ctx, unsigned char *p, int total) png_mask_transparency(&png, image); if (png.transparency || png.n == 2 || png.n == 4) - fz_premultiply_pixmap(image); + fz_premultiply_pixmap(png.ctx, image); fz_free(png.ctx, png.samples); diff --git a/fitz/image_tiff.c b/fitz/image_tiff.c index e476db33..fff91a9e 100644 --- a/fitz/image_tiff.c +++ b/fitz/image_tiff.c @@ -795,7 +795,7 @@ fz_load_tiff(fz_context *ctx, unsigned char *buf, int len) fz_drop_pixmap(ctx, image); image = rgb; } - fz_premultiply_pixmap(image); + fz_premultiply_pixmap(ctx, image); } } fz_always(ctx) diff --git a/fitz/res_bitmap.c b/fitz/res_bitmap.c index c381fc3c..2aa28b02 100644 --- a/fitz/res_bitmap.c +++ b/fitz/res_bitmap.c @@ -20,10 +20,11 @@ fz_new_bitmap(fz_context *ctx, int w, int h, int n) } fz_bitmap * -fz_keep_bitmap(fz_bitmap *pix) +fz_keep_bitmap(fz_context *ctx, fz_bitmap *bit) { - pix->refs++; - return pix; + if (bit) + bit->refs++; + return bit; } void @@ -37,7 +38,7 @@ fz_drop_bitmap(fz_context *ctx, fz_bitmap *bit) } void -fz_clear_bitmap(fz_bitmap *bit) +fz_clear_bitmap(fz_context *ctx, fz_bitmap *bit) { memset(bit->samples, 0, bit->stride * bit->h); } diff --git a/fitz/res_font.c b/fitz/res_font.c index 9f1bc73b..47dc96d5 100644 --- a/fitz/res_font.c +++ b/fitz/res_font.c @@ -698,7 +698,7 @@ fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix trm, fz_co bbox.y1++; glyph = fz_new_pixmap_with_rect(ctx, model ? model : fz_device_gray, bbox); - fz_clear_pixmap(glyph); + fz_clear_pixmap(ctx, glyph); ctm = fz_concat(font->t3matrix, trm); dev = fz_new_draw_device_type3(ctx, glyph); diff --git a/fitz/res_halftone.c b/fitz/res_halftone.c index b1b8d7b4..7258ad01 100644 --- a/fitz/res_halftone.c +++ b/fitz/res_halftone.c @@ -16,9 +16,10 @@ fz_new_halftone(fz_context *ctx, int comps) } fz_halftone * -fz_keep_halftone(fz_halftone *ht) +fz_keep_halftone(fz_context *ctx, fz_halftone *ht) { - ht->refs++; + if (ht) + ht->refs++; return ht; } diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c index 1998c7fc..69ae18ea 100644 --- a/fitz/res_pixmap.c +++ b/fitz/res_pixmap.c @@ -112,13 +112,13 @@ fz_bound_pixmap(fz_pixmap *pix) } void -fz_clear_pixmap(fz_pixmap *pix) +fz_clear_pixmap(fz_context *ctx, fz_pixmap *pix) { memset(pix->samples, 0, pix->w * pix->h * pix->n); } void -fz_clear_pixmap_with_color(fz_pixmap *pix, int value) +fz_clear_pixmap_with_color(fz_context *ctx, fz_pixmap *pix, int value) { if (value == 255) memset(pix->samples, 255, pix->w * pix->h * pix->n); @@ -139,7 +139,7 @@ fz_clear_pixmap_with_color(fz_pixmap *pix, int value) } void -fz_copy_pixmap_rect(fz_pixmap *dest, fz_pixmap *src, fz_bbox r) +fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, fz_bbox r) { const unsigned char *srcp; unsigned char *destp; @@ -167,7 +167,7 @@ fz_copy_pixmap_rect(fz_pixmap *dest, fz_pixmap *src, fz_bbox r) } void -fz_clear_pixmap_rect_with_color(fz_pixmap *dest, int value, fz_bbox r) +fz_clear_pixmap_rect_with_color(fz_context *ctx, fz_pixmap *dest, int value, fz_bbox r) { unsigned char *destp; int x, y, w, k, destspan; @@ -203,7 +203,7 @@ fz_clear_pixmap_rect_with_color(fz_pixmap *dest, int value, fz_bbox r) } void -fz_premultiply_pixmap(fz_pixmap *pix) +fz_premultiply_pixmap(fz_context *ctx, fz_pixmap *pix) { unsigned char *s = pix->samples; unsigned char a; @@ -222,7 +222,7 @@ fz_premultiply_pixmap(fz_pixmap *pix) } void -fz_unmultiply_pixmap(fz_pixmap *pix) +fz_unmultiply_pixmap(fz_context *ctx, fz_pixmap *pix) { unsigned char *s = pix->samples; int a, inva; @@ -267,7 +267,7 @@ fz_alpha_from_gray(fz_context *ctx, fz_pixmap *gray, int luminosity) } void -fz_invert_pixmap(fz_pixmap *pix) +fz_invert_pixmap(fz_context *ctx, fz_pixmap *pix) { unsigned char *s = pix->samples; int k, x, y; @@ -284,7 +284,7 @@ fz_invert_pixmap(fz_pixmap *pix) } void -fz_gamma_pixmap(fz_pixmap *pix, float gamma) +fz_gamma_pixmap(fz_context *ctx, fz_pixmap *pix, float gamma) { unsigned char gamma_map[256]; unsigned char *s = pix->samples; @@ -543,7 +543,7 @@ fz_write_png(fz_context *ctx, fz_pixmap *pixmap, char *filename, int savealpha) } unsigned int -fz_pixmap_size(fz_pixmap * pix) +fz_pixmap_size(fz_context *ctx, fz_pixmap * pix) { if (pix == NULL) return 0; diff --git a/fitz/stm_buffer.c b/fitz/stm_buffer.c index f01e5b19..7f9d521d 100644 --- a/fitz/stm_buffer.c +++ b/fitz/stm_buffer.c @@ -25,9 +25,10 @@ fz_new_buffer(fz_context *ctx, int size) } fz_buffer * -fz_keep_buffer(fz_buffer *buf) +fz_keep_buffer(fz_context *ctx, fz_buffer *buf) { - buf->refs ++; + if (buf) + buf->refs ++; return buf; } diff --git a/fitz/stm_open.c b/fitz/stm_open.c index 37230243..6a987103 100644 --- a/fitz/stm_open.c +++ b/fitz/stm_open.c @@ -162,7 +162,7 @@ fz_open_buffer(fz_context *ctx, fz_buffer *buf) { fz_stream *stm; - fz_keep_buffer(buf); + fz_keep_buffer(ctx, buf); stm = fz_new_stream(ctx, buf, read_buffer, close_buffer); stm->seek = seek_buffer; diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c index 1bad44eb..c9359508 100644 --- a/pdf/pdf_image.c +++ b/pdf/pdf_image.c @@ -380,7 +380,7 @@ pdf_load_image(pdf_document *xref, fz_obj *dict) pix = pdf_load_image_imp(xref, NULL, dict, NULL, 0); /* RJW: "cannot load image (%d 0 R)", fz_to_num(dict) */ - fz_store_item(ctx, dict, pix, fz_pixmap_size(pix)); + fz_store_item(ctx, dict, pix, fz_pixmap_size(ctx, pix)); return pix; } |