changeset 7229:1aec26077b48

Follow-up for RT-32213: Use ImageTools.readFully method.
author vadim
date Tue, 10 Jun 2014 17:08:10 +0400
parents 815505eb4abc
children c11fe70cde3c
files modules/graphics/src/main/java/com/sun/javafx/iio/bmp/BMPImageLoaderFactory.java
diffstat 1 files changed, 5 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/iio/bmp/BMPImageLoaderFactory.java	Tue Jun 10 16:52:04 2014 +0400
+++ b/modules/graphics/src/main/java/com/sun/javafx/iio/bmp/BMPImageLoaderFactory.java	Tue Jun 10 17:08:10 2014 +0400
@@ -77,21 +77,6 @@
             throw new EOFException();
         }
     }
-
-    public void readFully(byte[] b) throws IOException {
-        readFully(b, 0, b.length);
-    }
-
-    public void readFully(byte[] b, int off, int len) throws IOException {
-        while (len > 0) {
-            int nbytes = in.read(b, off, len);
-            if (nbytes == -1) {
-                throw new EOFException();
-            }
-            off += nbytes;
-            len -= nbytes;
-        }
-    }
 }
 
 final class BitmapInfoHeader {
@@ -227,7 +212,7 @@
             imgSize = bfSize - bfOffBits;
         }
         byte imgData[] = new byte[imgSize];
-        data.readFully(imgData);
+        ImageTools.readFully(data.in, imgData);
 
         boolean isBottomUp = bih.biHeight > 0;
         int line = isBottomUp ? hght - 1 : 0;
@@ -310,7 +295,7 @@
 
         byte lineBuf[] = new byte[srcStride];
         for (int i = 0; i != hght; ++i) {
-            data.readFully(lineBuf);
+            ImageTools.readFully(data.in, lineBuf);
             int line = bih.biHeight < 0 ? i : hght - i - 1;
             int dstOffset = line * rowLength;
 
@@ -343,7 +328,7 @@
         int srcStride = (bytesPerLine + 3) & ~3;
         byte lineBuf[] = new byte[srcStride];
         for (int i = 0; i != hght; ++i) {
-            data.readFully(lineBuf);
+            ImageTools.readFully(data.in, lineBuf);
             int line = bih.biHeight < 0 ? i : hght - i - 1;
             int dstOffset = line * rowLength;
 
@@ -360,7 +345,7 @@
         int bytesPerLine = bih.biWidth * 4;
         byte lineBuf[] = new byte[bytesPerLine];
         for (int i = 0; i != hght; ++i) {
-            data.readFully(lineBuf);
+            ImageTools.readFully(data.in, lineBuf);
             int line = bih.biHeight < 0 ? i : hght - i - 1;
             int dstOff = line * rowLength;
 
@@ -380,7 +365,7 @@
         for (int i = 0; i != hght; ++i) {
             int line = bih.biHeight < 0 ? i : hght - i - 1;
             int lineOffset = line * rowLength;
-            data.readFully(image, lineOffset, rowLength);
+            ImageTools.readFully(data.in, image, lineOffset, rowLength);
             data.skipBytes(padding);
             BGRtoRGB(image, lineOffset, rowLength);
         }