All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jme3.texture.plugins.AndroidNativeImageLoader Maven / Gradle / Ivy

There is a newer version: 3.7.0-stable
Show newest version
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