From: Keiron Liddle Date: Fri, 2 Aug 2002 06:44:46 +0000 (+0000) Subject: workaround for eps files that have invalid float bounding box values X-Git-Tag: Alt-Design-integration-base~480 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5d1208bcd158014ddc52f76ee11ab1e71499e342;p=xmlgraphics-fop.git workaround for eps files that have invalid float bounding box values float values are rounded off according to the spec the %%HiResBoundingBox should be used instead for floating poitn values Submitted by: Torsten Erler git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195048 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/image/analyser/EPSReader.java b/src/org/apache/fop/image/analyser/EPSReader.java index a0060b58c..0e7948fb2 100644 --- a/src/org/apache/fop/image/analyser/EPSReader.java +++ b/src/org/apache/fop/image/analyser/EPSReader.java @@ -170,20 +170,29 @@ public class EPSReader implements ImageReader { } private int readLongString(EPSImage.EPSData data, long[] mbbox, int i, int idx) { - while (idx < data.epsFile.length && (data.epsFile[idx] == 32)) - idx++; + while (idx < data.epsFile.length && (data.epsFile[idx] == 32)) { + idx++; + } int nidx = idx; + // check also for ANSI46(".") to identify floating point values while (nidx < data.epsFile.length && ((data.epsFile[nidx] >= 48 && data.epsFile[nidx] <= 57) || - (data.epsFile[nidx] == 45))) + (data.epsFile[nidx] == 45) || (data.epsFile[nidx] == 46) )) { nidx++; + } byte[] num = new byte[nidx - idx]; System.arraycopy(data.epsFile, idx, num, 0, nidx - idx); String ns = new String(num); - mbbox[i] = Long.parseLong(ns); + + //if( ns.indexOf(".") != -1 ) { + // do something like logging a warning + //} + + // then parse the double and round off to the next math. Integer + mbbox[i] = (long) Math.ceil( Double.parseDouble( ns ) ); return (1 + nidx - idx); } @@ -191,6 +200,5 @@ public class EPSReader implements ImageReader { public String getMimeType() { return "image/eps"; } - }