summaryrefslogtreecommitdiff
path: root/pdf/pdf_image.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2011-09-11 19:29:42 -0500
committerRobin Watts <robin.watts@artifex.com>2011-09-14 17:44:13 +0100
commit89ae81f651bfa112b8e07317eb6983beaf7cb212 (patch)
tree3f99dad1253b795629e66d45b915c1d72043242b /pdf/pdf_image.c
parentcefb81f1886685580a40b17b5e495a8a8a1ebeaf (diff)
downloadmupdf-89ae81f651bfa112b8e07317eb6983beaf7cb212.tar.xz
Initial import of exception handling code
Import exception handling code from WSS, modified to fit into the fitz world. With this code we have 'real' fz_try/fz_catch/fz_rethrow functions, handling a fz_except type. We therefore rename the existing fz_throw/ fz_catch/fz_rethrow to be fz_error_make/fz_error_handle/fz_error_note. We don't actually use fz_try/fz_catch/fz_rethrow yet...
Diffstat (limited to 'pdf/pdf_image.c')
-rw-r--r--pdf/pdf_image.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c
index e1901100..413efc98 100644
--- a/pdf/pdf_image.c
+++ b/pdf/pdf_image.c
@@ -53,13 +53,13 @@ pdf_load_image_imp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict,
tile = NULL;
error = pdf_load_jpx_image(&tile, xref, dict);
if (error)
- return fz_rethrow(error, "cannot load jpx image");
+ return fz_error_note(error, "cannot load jpx image");
if (forcemask)
{
if (tile->n != 2)
{
fz_drop_pixmap(tile);
- return fz_throw("softmask must be grayscale");
+ return fz_error_make("softmask must be grayscale");
}
mask = fz_alpha_from_gray(tile, 1);
fz_drop_pixmap(tile);
@@ -85,17 +85,17 @@ pdf_load_image_imp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict,
bpc = 1;
if (w == 0)
- return fz_throw("image width is zero");
+ return fz_error_make("image width is zero");
if (h == 0)
- return fz_throw("image height is zero");
+ return fz_error_make("image height is zero");
if (bpc == 0)
- return fz_throw("image depth is zero");
+ return fz_error_make("image depth is zero");
if (bpc > 16)
- return fz_throw("image depth is too large: %d", bpc);
+ return fz_error_make("image depth is too large: %d", bpc);
if (w > (1 << 16))
- return fz_throw("image is too wide");
+ return fz_error_make("image is too wide");
if (h > (1 << 16))
- return fz_throw("image is too high");
+ return fz_error_make("image is too high");
obj = fz_dict_getsa(dict, "ColorSpace", "CS");
if (obj && !imagemask && !forcemask)
@@ -110,7 +110,7 @@ pdf_load_image_imp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict,
error = pdf_load_colorspace(&colorspace, xref, obj);
if (error)
- return fz_rethrow(error, "cannot load image colorspace");
+ return fz_error_note(error, "cannot load image colorspace");
if (!strcmp(colorspace->name, "Indexed"))
indexed = 1;
@@ -146,7 +146,7 @@ pdf_load_image_imp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict,
{
if (colorspace)
fz_drop_colorspace(colorspace);
- return fz_rethrow(error, "cannot load image mask/softmask");
+ return fz_error_note(error, "cannot load image mask/softmask");
}
}
}
@@ -165,7 +165,7 @@ pdf_load_image_imp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict,
fz_drop_colorspace(colorspace);
if (mask)
fz_drop_pixmap(mask);
- return fz_throw("out of memory");
+ return fz_error_make("out of memory");
}
if (colorspace)
@@ -186,7 +186,7 @@ pdf_load_image_imp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict,
if (error)
{
fz_drop_pixmap(tile);
- return fz_rethrow(error, "cannot open image data stream (%d 0 R)", fz_to_num(dict));
+ return fz_error_note(error, "cannot open image data stream (%d 0 R)", fz_to_num(dict));
}
}
@@ -198,7 +198,7 @@ pdf_load_image_imp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict,
fz_close(stm);
fz_free(samples);
fz_drop_pixmap(tile);
- return fz_rethrow(len, "cannot read image data");
+ return fz_error_note(len, "cannot read image data");
}
/* Make sure we read the EOF marker (for inline images only) */
@@ -207,7 +207,7 @@ pdf_load_image_imp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict,
unsigned char tbuf[512];
int tlen = fz_read(stm, tbuf, sizeof tbuf);
if (tlen < 0)
- fz_catch(tlen, "ignoring error at end of image");
+ fz_error_handle(tlen, "ignoring error at end of image");
if (tlen > 0)
fz_warn("ignoring garbage at end of image");
}
@@ -262,7 +262,7 @@ pdf_load_inline_image(fz_pixmap **pixp, pdf_xref *xref, fz_obj *rdb, fz_obj *dic
error = pdf_load_image_imp(pixp, xref, rdb, dict, file, 0);
if (error)
- return fz_rethrow(error, "cannot load inline image");
+ return fz_error_note(error, "cannot load inline image");
return fz_okay;
}
@@ -295,14 +295,14 @@ pdf_load_jpx_image(fz_pixmap **imgp, pdf_xref *xref, fz_obj *dict)
error = pdf_load_stream(&buf, xref, fz_to_num(dict), fz_to_gen(dict));
if (error)
- return fz_rethrow(error, "cannot load jpx image data");
+ return fz_error_note(error, "cannot load jpx image data");
obj = fz_dict_gets(dict, "ColorSpace");
if (obj)
{
error = pdf_load_colorspace(&colorspace, xref, obj);
if (error)
- fz_catch(error, "cannot load image colorspace");
+ fz_error_handle(error, "cannot load image colorspace");
}
error = fz_load_jpx_image(&img, buf->data, buf->len, colorspace);
@@ -311,7 +311,7 @@ pdf_load_jpx_image(fz_pixmap **imgp, pdf_xref *xref, fz_obj *dict)
if (colorspace)
fz_drop_colorspace(colorspace);
fz_drop_buffer(buf);
- return fz_rethrow(error, "cannot load jpx image");
+ return fz_error_note(error, "cannot load jpx image");
}
if (colorspace)
@@ -325,7 +325,7 @@ pdf_load_jpx_image(fz_pixmap **imgp, pdf_xref *xref, fz_obj *dict)
if (error)
{
fz_drop_pixmap(img);
- return fz_rethrow(error, "cannot load image mask/softmask");
+ return fz_error_note(error, "cannot load image mask/softmask");
}
}
@@ -346,7 +346,7 @@ pdf_load_image(fz_pixmap **pixp, pdf_xref *xref, fz_obj *dict)
error = pdf_load_image_imp(pixp, xref, NULL, dict, NULL, 0);
if (error)
- return fz_rethrow(error, "cannot load image (%d 0 R)", fz_to_num(dict));
+ return fz_error_note(error, "cannot load image (%d 0 R)", fz_to_num(dict));
pdf_store_item(xref->store, fz_keep_pixmap, fz_drop_pixmap, dict, *pixp);