From 5923cda517a8ac54ebffc1e0fc416b979a01e4cd Mon Sep 17 00:00:00 2001 From: sgold Date: Thu, 20 Mar 2014 08:09:42 +0000 Subject: [PATCH] Bugfix: issue #637 (load ICO asset from JAR) in gradle-restructure branch git-svn-id: https://jmonkeyengine.googlecode.com/svn/branches/gradle-restructure@11106 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../java/com/jme3/cursors/plugins/CursorLoader.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/jme3-desktop/src/main/java/com/jme3/cursors/plugins/CursorLoader.java b/jme3-desktop/src/main/java/com/jme3/cursors/plugins/CursorLoader.java index c49c31834..d3e71fcad 100644 --- a/jme3-desktop/src/main/java/com/jme3/cursors/plugins/CursorLoader.java +++ b/jme3-desktop/src/main/java/com/jme3/cursors/plugins/CursorLoader.java @@ -41,6 +41,7 @@ import java.awt.image.AffineTransformOp; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.DataInput; import java.io.DataInputStream; import java.io.IOException; @@ -210,13 +211,13 @@ public class CursorLoader implements AssetLoader { } } else if (isIco) { DataInputStream in = new DataInputStream(inStream); - int bytesToRead; - while ((bytesToRead = in.available()) != 0) { - byte[] icoimage2 = new byte[icoimages.length + bytesToRead]; - System.arraycopy(icoimages, 0, icoimage2, 0, icoimages.length); - in.read(icoimage2, icoimages.length, bytesToRead); - icoimages = icoimage2; + ByteArrayOutputStream out = new ByteArrayOutputStream(); + byte[] buffer = new byte[16384]; + int bytesRead; + while ((bytesRead = in.read(buffer)) >= 0) { + out.write(buffer, 0, bytesRead); } + icoimages = out.toByteArray(); } BufferedImage bi[] = parseICOImage(icoimages);