Example usage for com.badlogic.gdx.graphics.g2d Gdx2DPixmap Gdx2DPixmap

List of usage examples for com.badlogic.gdx.graphics.g2d Gdx2DPixmap Gdx2DPixmap

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g2d Gdx2DPixmap Gdx2DPixmap.

Prototype

public Gdx2DPixmap(ByteBuffer pixelPtr, long[] nativeData) 

Source Link

Usage

From source file:com.idp.engine.net.IdpImageListener.java

@Override
public void handleHttpResponse(final Net.HttpResponse httpResponse) {

    int statusCode = httpResponse.getStatus().getStatusCode();

    if (statusCode < 200 || statusCode >= 300) {
        failed(new GdxRuntimeException("failed with code " + statusCode));
        return;//from  w w  w .ja  v a2 s . com
    }

    try {
        InputStream stream = httpResponse.getResultAsStream();
        Gdx2DPixmap pixmap = new Gdx2DPixmap(stream, Gdx2DPixmap.GDX2D_FORMAT_RGBA8888);
        IdpAssetManager.getInstance().cachePixmap(url, pixmap);
        Gdx.app.postRunnable(new Runnable() {
            public void run() {
                loaded(IdpAssetManager.getInstance().getTextureFromCache(url));
            }
        });
    } catch (Exception ex) {
        failed(ex);
    }
}

From source file:dk.gruppe7.core.LibGDXGraphicsInterpreter.java

private Texture inputStreamToTexture(InputStream inputStream) {
    if (cachedTextures.containsKey(inputStream.hashCode()))
        return cachedTextures.get(inputStream.hashCode());

    Gdx2DPixmap gpm = null;/*from w  w  w  .  j  a va  2s  .  com*/

    try {
        gpm = new Gdx2DPixmap(inputStream, Gdx2DPixmap.GDX2D_FORMAT_RGBA8888);
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }

    Pixmap pixmap = new Pixmap(gpm);
    Texture texture = new Texture(pixmap);

    cachedTextures.put(inputStream.hashCode(), texture);
    return texture;
}

From source file:me.scarlet.undertailor.gfx.spritesheet.PackagedSpriteSheetFactory.java

License:Open Source License

@Override
protected CompletableFuture<Texture> loadDisposable() {
    InputStream textureStream = null;
    try { // load the spritesheet here
        textureStream = sourceFile.getInputStream(sourceFile.getEntry(ENTRY_SPRITESHEET));
        Gdx2DPixmap readMap = new Gdx2DPixmap(textureStream, Gdx2DPixmap.GDX2D_FORMAT_RGBA8888);
        Texture texture = new Texture(new Pixmap(readMap));
        readMap.dispose();//  w  ww . j av a2s. c  om

        this.loadSheet(texture);

        return CompletableFuture.completedFuture(texture);
    } catch (Exception e) {
        log.error("Failed to load packaged spritesheet", e);
    } finally {
        StreamUtil.closeQuietly(textureStream);
    }

    return null;
}