From 04d3509c589722ec5de0ab63936b378fd4238c0d Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Tue, 26 Jul 2011 10:54:28 +0000 Subject: [PATCH] Improving image loading speed by using the BufferedInputStream. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7922 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../blender/helpers/v249/TextureHelper.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/TextureHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/TextureHelper.java index b2d8a7957..45c0f368c 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/TextureHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/TextureHelper.java @@ -34,6 +34,7 @@ package com.jme3.scene.plugins.blender.helpers.v249; import java.awt.color.ColorSpace; import java.awt.image.BufferedImage; import java.awt.image.ColorConvertOp; +import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -1694,7 +1695,7 @@ public class TextureHelper extends AbstractBlenderHelper { protected Texture loadTextureFromFile(String name, DataRepository dataRepository) { Image image = null; ImageLoader imageLoader = new ImageLoader(); - FileInputStream fis = null; + BufferedInputStream bis = null; ImageType[] imageTypes = ImageType.values(); // TODO: would be nice to have the model asset key here to getthe models older in the assetmanager @@ -1725,14 +1726,15 @@ public class TextureHelper extends AbstractBlenderHelper { LOGGER.log(Level.INFO, "Trying with: {0}", name); try { for (int i = 0; i < imageTypes.length && image == null; ++i) { - fis = new FileInputStream(textureFile); - image = imageLoader.loadImage(fis, imageTypes[i], false); + FileInputStream fis = new FileInputStream(textureFile); + bis = new BufferedInputStream(fis); + image = imageLoader.loadImage(bis, imageTypes[i], false); this.closeStream(fis); } } catch (FileNotFoundException e) { assert false : e;// this should NEVER happen } finally { - this.closeStream(fis); + this.closeStream(bis); } } } @@ -1749,13 +1751,14 @@ public class TextureHelper extends AbstractBlenderHelper { LOGGER.info("Trying with: " + texName); try { for (int i = 0; i < imageTypes.length && image == null; ++i) { - fis = new FileInputStream(textureFile); - image = imageLoader.loadImage(fis, imageTypes[i], false); + FileInputStream fis = new FileInputStream(textureFile); + bis = new BufferedInputStream(fis); + image = imageLoader.loadImage(bis, imageTypes[i], false); } } catch (FileNotFoundException e) { assert false : e;// this should NEVER happen } finally { - this.closeStream(fis); + this.closeStream(bis); } } if (idx > 1) {