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

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

Introduction

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

Prototype

int GDX2D_FORMAT_RGBA8888

To view the source code for com.badlogic.gdx.graphics.g2d Gdx2DPixmap GDX2D_FORMAT_RGBA8888.

Click 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;//ww  w  .jav a2s . c om
    }

    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  ww.  j ava  2 s .c  o m

    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 a  v a  2  s.  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;
}