From a24dd0ec500ecdaf808822ab67c59213898c12f1 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 23 Feb 2016 12:29:32 +0100 Subject: Add fz_new_image_from_file. --- source/fitz/image.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source/fitz') diff --git a/source/fitz/image.c b/source/fitz/image.c index 59e2ab56..a2f4bed2 100644 --- a/source/fitz/image.c +++ b/source/fitz/image.c @@ -545,6 +545,23 @@ fz_new_image_from_buffer(fz_context *ctx, fz_buffer *buffer) return fz_new_image(ctx, w, h, 8, cspace, xres, yres, 0, 0, NULL, NULL, bc, NULL); } +fz_image * +fz_new_image_from_file(fz_context *ctx, const char *path) +{ + fz_buffer *buffer; + fz_image *image; + + buffer = fz_read_file(ctx, path); + fz_try(ctx) + image = fz_new_image_from_buffer(ctx, buffer); + fz_always(ctx) + fz_drop_buffer(ctx, buffer); + fz_catch(ctx) + fz_rethrow(ctx); + + return image; +} + void fz_image_resolution(fz_image *image, int *xres, int *yres) { -- cgit v1.2.3