diff options
author | Jonathan Kew <jfkthame@googlemail.com> | 2008-05-21 13:19:17 +0000 |
---|---|---|
committer | Jonathan Kew <jfkthame@googlemail.com> | 2008-05-21 13:19:17 +0000 |
commit | ebdcfba2fc6c9bf4db2008a00058f3422a9d1da8 (patch) | |
tree | 52772b6cbe81d9ca8b67d3990ea033a27d432916 /Build/source/texk/xdvipdfmx/src/pdfximage.c | |
parent | 246e3a9180a28cb419402687d2005bdfb5313774 (diff) |
update to xdvipdfmx 0.7, from xetex svn r.688
git-svn-id: svn://tug.org/texlive/trunk@8272 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/xdvipdfmx/src/pdfximage.c')
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/pdfximage.c | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/Build/source/texk/xdvipdfmx/src/pdfximage.c b/Build/source/texk/xdvipdfmx/src/pdfximage.c index c67b8047b73..a5569865159 100644 --- a/Build/source/texk/xdvipdfmx/src/pdfximage.c +++ b/Build/source/texk/xdvipdfmx/src/pdfximage.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.c,v 1.17 2008/02/13 20:22:21 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.c,v 1.20 2008/05/17 01:16:53 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -109,11 +109,19 @@ static struct ic_ _ic = { }; static void -pdf_init_ximage_struct (pdf_ximage *I) +pdf_init_ximage_struct (pdf_ximage *I, const char *ident, const char *filename) { - I->ident = NULL; + if (ident) { + I->ident = NEW(strlen(ident)+1, char); + strcpy(I->ident, ident); + } else + I ->ident = NULL; I->page_no = I->page_count = 0; - I->filename = NULL; + if (filename) { + I->filename = NEW(strlen(filename)+1, char); + strcpy(I->filename, filename); + } else + I->filename = NULL; I->subtype = -1; memset(I->res_name, 0, 16); I->reference = NULL; @@ -137,7 +145,7 @@ pdf_clean_ximage_struct (pdf_ximage *I) pdf_release_obj(I->reference); if (I->resource) pdf_release_obj(I->resource); - pdf_init_ximage_struct(I); + pdf_init_ximage_struct(I, NULL, NULL); } @@ -270,7 +278,7 @@ load_image (const char *ident, } I = &ic->ximages[id]; - pdf_init_ximage_struct(I); + pdf_init_ximage_struct(I, ident, ident); pdf_ximage_set_page(I, page_no, 0); switch (format) { @@ -278,7 +286,7 @@ load_image (const char *ident, if (_opts.verbose) MESG("[JPEG]"); if (jpeg_include_image(I, fp) < 0) - return -1; + goto error; I->subtype = PDF_XOBJECT_TYPE_IMAGE; break; #ifdef HAVE_LIBPNG @@ -286,7 +294,7 @@ load_image (const char *ident, if (_opts.verbose) MESG("[PNG]"); if (png_include_image(I, fp) < 0) - return -1; + goto error; I->subtype = PDF_XOBJECT_TYPE_IMAGE; break; #endif @@ -294,39 +302,29 @@ load_image (const char *ident, if (_opts.verbose) MESG("[BMP]"); if (bmp_include_image(I, fp) < 0) - return -1; + goto error; I->subtype = PDF_XOBJECT_TYPE_IMAGE; break; case IMAGE_TYPE_PDF: if (_opts.verbose) MESG("[PDF]"); -// if (pdf_include_page(I, fp, page_index, pdf_box) < 0) if (pdf_include_page(I, fp) < 0) - return -1; - I->subtype = PDF_XOBJECT_TYPE_FORM; -// I->page_index = page_index; -// I->pdf_box = pdf_box; - break; - case IMAGE_TYPE_EPS: + goto error; if (_opts.verbose) - MESG("[PS]"); - if (ps_include_page(I, fullname) < 0) - return -1; + MESG(",Page:%ld", I->page_no); I->subtype = PDF_XOBJECT_TYPE_FORM; break; + // case IMAGE_TYPE_EPS: default: if (_opts.verbose) - MESG("[UNKNOWN]"); + MESG(format == IMAGE_TYPE_EPS ? "[PS]" : "[UNKNOWN]"); if (ps_include_page(I, fullname) < 0) - return -1; + goto error; + if (_opts.verbose) + MESG(",Page:%ld", I->page_no); I->subtype = PDF_XOBJECT_TYPE_FORM; } - I->filename = NEW(strlen(ident)+1, char); - I->ident = NEW(strlen(ident)+1, char); - strcpy(I->filename, ident); - strcpy(I->ident, ident); - switch (I->subtype) { case PDF_XOBJECT_TYPE_IMAGE: sprintf(I->res_name, "Im%d", id); @@ -336,12 +334,16 @@ load_image (const char *ident, break; default: ERROR("Unknown XObject subtype: %d", I->subtype); - return -1; + goto error; } ic->count++; return id; + + error: + pdf_clean_ximage_struct(I); + return -1; } @@ -392,7 +394,12 @@ pdf_ximage_findresource (const char *ident, long page_no) if (_opts.verbose) MESG("[MPS]"); id = mps_include_page(ident, fp); - break; + if (id < 0) { + WARN("Try again with the distiller."); + format = IMAGE_TYPE_EPS; + rewind(fp); + } else + break; default: id = load_image(ident, fullname, format, fp, page_no); break; @@ -482,6 +489,12 @@ pdf_ximage_init_image_info (ximage_info *info) info->xdensity = info->ydensity = 1.0; } +char * +pdf_ximage_get_ident (pdf_ximage *I) +{ + return I->ident; +} + void pdf_ximage_set_image (pdf_ximage *I, void *image_info, pdf_obj *resource) { @@ -583,11 +596,7 @@ pdf_ximage_defineresource (const char *ident, I = &ic->ximages[id]; - pdf_init_ximage_struct(I); - if (ident) { - I->ident = NEW(strlen(ident) + 1, char); - strcpy(I->ident, ident); - } + pdf_init_ximage_struct(I, ident, NULL); switch (subtype) { case PDF_XOBJECT_TYPE_IMAGE: |