From 51427b92a2d9cd3fc619854e26536c9c6adad947 Mon Sep 17 00:00:00 2001 From: Sven Gothel <sgothel@jausoft.com> Date: Tue, 2 Jul 2013 22:25:23 +0200 Subject: PNGJ: Bump to git sha1 a0b1101ba2d37de39428ed55c8189502e24a3125 of https://code.google.com/p/pngj/ --- .../jogamp/opengl/util/pngj/PngHelperInternal.java | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java') diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java index 63edf8d17..a950c6b33 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java @@ -144,18 +144,23 @@ public class PngHelperInternal { } } - public static void skipBytes(InputStream is, int len) { - byte[] buf = new byte[8192 * 4]; - int read, remain = len; + public static void skipBytes(InputStream is, long len) { try { - while (remain > 0) { - read = is.read(buf, 0, remain > buf.length ? buf.length : remain); - if (read < 0) - throw new PngjInputException("error reading (skipping) : EOF"); - remain -= read; + while (len > 0) { + long n1 = is.skip(len); + if (n1 > 0) { + len -= n1; + } else if (n1 == 0) { // should we retry? lets read one byte + if (is.read() == -1) // EOF + break; + else + len--; + } else + // negative? this should never happen but... + throw new IOException("skip() returned a negative value ???"); } } catch (IOException e) { - throw new PngjInputException("error reading (skipping)", e); + throw new PngjInputException(e); } } -- cgit v1.2.3