From: Niki Roo Date: Sun, 28 Apr 2019 17:18:24 +0000 (+0200) Subject: bufixes X-Git-Tag: fanfix-swing-0.0.1~21^2~106 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=f04d5e49e91832e122617fbbaa5cdb053459a7e7;p=fanfix-swing.git bufixes --- diff --git a/src/be/nikiroo/utils/Image.java b/src/be/nikiroo/utils/Image.java index cfcaa74e..ace43ded 100644 --- a/src/be/nikiroo/utils/Image.java +++ b/src/be/nikiroo/utils/Image.java @@ -7,6 +7,8 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import be.nikiroo.utils.streams.MarkableFileInputStream; + /** * This class represents an image data. * @@ -91,7 +93,7 @@ public class Image implements Closeable { * in case of I/O error */ public InputStream newInputStream() throws IOException { - return new FileInputStream(data); + return new MarkableFileInputStream(new FileInputStream(data)); } /** diff --git a/src/be/nikiroo/utils/streams/BufferedInputStream.java b/src/be/nikiroo/utils/streams/BufferedInputStream.java index af1e2ac9..397f6fcf 100644 --- a/src/be/nikiroo/utils/streams/BufferedInputStream.java +++ b/src/be/nikiroo/utils/streams/BufferedInputStream.java @@ -249,7 +249,7 @@ public class BufferedInputStream extends InputStream { while (hasMoreData() && done < blen) { preRead(); if (hasMoreData()) { - int now = Math.min(blen, stop) - start; + int now = Math.min(blen - done, stop - start); if (now > 0) { System.arraycopy(buffer, start, b, boff + done, now); start += now;