List of usage examples for com.badlogic.gdx.graphics TextureData consumePixmap
public Pixmap consumePixmap();
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 w ww. j a va 2s . co m*/ } 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.jav a 2s. com 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 . j a v a 2 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(); } }