com.jme3.texture.plugins.AndroidNativeImageLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jme3-android Show documentation
Show all versions of jme3-android Show documentation
jMonkeyEngine is a 3D game engine for adventurous Java developers
package com.jme3.texture.plugins;
import com.jme3.asset.AssetInfo;
import com.jme3.asset.AssetLoader;
import com.jme3.asset.TextureKey;
import com.jme3.texture.Image;
import java.io.IOException;
import java.io.InputStream;
/**
* Native image loader to deal with filetypes that support alpha channels.
* The Android Bitmap class premultiplies the channels by the alpha when
* loading. This loader does not.
*
* @author iwgeric
* @author Kirill Vainer
*/
public class AndroidNativeImageLoader implements AssetLoader {
private final byte[] tmpArray = new byte[10 * 1024];
static {
System.loadLibrary("decodejme");
}
private static native Image load(InputStream in, boolean flipY, byte[] tmpArray) throws IOException;
@Override
public Image load(AssetInfo info) throws IOException {
boolean flip = ((TextureKey) info.getKey()).isFlipY();
InputStream in = null;
try {
in = info.openStream();
return load(in, flip, tmpArray);
} finally {
if (in != null){
in.close();
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy