Example usage for com.badlogic.gdx.graphics TextureData prepare

List of usage examples for com.badlogic.gdx.graphics TextureData prepare

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics TextureData prepare.

Prototype

public void prepare();

Source Link

Document

Prepares the TextureData for a call to #consumePixmap() or #consumeCustomData(int) .

Usage

From source file:com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite.java

License:Open Source License

public static int pick(int index, int x, int y) {
    GdxTexture bmp = TextureCache.get(Assets.ITEMS).bitmap;
    int rows = bmp.getWidth() / SIZE;
    int row = index / rows;
    int col = index % rows;
    // FIXME: I'm assuming this is super slow?
    final TextureData td = bmp.getTextureData();
    if (!td.isPrepared()) {
        td.prepare();
    }//from   www  .  j  a v  a 2 s . com
    final Pixmap pixmap = td.consumePixmap();
    int pixel = pixmap.getPixel(col * SIZE + x, row * SIZE + y);
    pixmap.dispose();
    return pixel;
}

From source file:com.watabou.noosa.particles.BitmaskEmitter.java

License:Open Source License

public BitmaskEmitter(Image target) {
    super();/*from   w  w w. j  a  v  a 2 s.c  o  m*/

    this.target = target;

    TextureData data = target.texture.bitmap.getTextureData();
    if (!data.isPrepared())
        data.prepare();
    map = data.consumePixmap();
    mapW = map.getWidth();
    mapH = map.getHeight();
}

From source file:de.myreality.acid.gdx.GdxCellRenderer.java

License:Open Source License

@Override
public void drawCell(float x, float y, float width, float height, float r, float g, float b, float a) {
    Texture buffer = renderer.getBuffer();
    if (buffer != null) {

        Pixmap map = new Pixmap((int) width, (int) height, Format.RGBA8888);
        map.setColor(r, g, b, a);//from  ww  w  .ja v a2 s  .c om

        if (image != null) {
            Sprite sprite = new Sprite(image);
            sprite.setColor(r, g, b, a);
            image = sprite.getTexture();
            TextureData data = image.getTextureData();
            data.prepare();
            Pixmap tmp = data.consumePixmap();
            map.drawPixmap(tmp, 0, 0, tmp.getWidth(), tmp.getHeight(), 0, 0, (int) width, (int) height);
            image.getTextureData().disposePixmap();
        } else {
            map.fillRectangle(0, 0, (int) width, (int) height);
        }

        buffer.draw(map, (int) x, (int) y);
        map.dispose();
    }
}

From source file:ta.shape3D.mesh.MeshTA.java

License:Apache License

public void save(DataOutputStream bos, File f) throws IOException {
    bos.writeFloat(tX);/*from w  w w  .  java 2s.c  o  m*/
    bos.writeFloat(tY);
    bos.writeFloat(tZ);
    bos.writeFloat(rX);
    bos.writeFloat(rY);
    bos.writeFloat(rZ);
    bos.writeFloat(scaleX);
    bos.writeFloat(scaleY);
    bos.writeFloat(scaleZ);
    bos.writeUTF(name);
    bos.writeInt(triangles.size());
    for (Triangle3D t : triangles) {
        t.save(bos);
    }
    System.out.println("yolo");
    if (image != null) {
        String s;
        if (f.getParentFile() != null)
            s = f.getParent() + "\\" + f.getName().split(".mta")[0] + "Image" + name + ".png";
        else
            s = f.getName().split(".mta")[0] + "Image" + name + ".png";
        System.out.println(s);
        bos.writeUTF(f.getName().split(".mta")[0] + "Image" + name + ".png");
        TextureData td = image.getTextureData();
        td.prepare();
        PixmapIO.writePNG(new FileHandle(s), image.getTextureData().consumePixmap());
    } else
        bos.writeUTF(new String());
    bos.writeInt(sousMesh.size());
    for (MeshTA m : sousMesh) {
        m.save(bos, f);
    }
}