本文整理匯總了Java中com.badlogic.gdx.graphics.Pixmap.dispose方法的典型用法代碼示例。如果您正苦於以下問題:Java Pixmap.dispose方法的具體用法?Java Pixmap.dispose怎麽用?Java Pixmap.dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.graphics.Pixmap
的用法示例。
在下文中一共展示了Pixmap.dispose方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: takeScreenshot
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public static void takeScreenshot() {
byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0,
Gdx.graphics.getBackBufferWidth(),
Gdx.graphics.getBackBufferHeight(), true);
Pixmap pixmap = new Pixmap(Gdx.graphics.getBackBufferWidth(),
Gdx.graphics.getBackBufferHeight(), Pixmap.Format.RGBA8888);
BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length);
SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyy-MM-dd HH-mm-ss");
PixmapIO.writePNG(
Gdx.files.external(dateFormat.format(new Date()) + ".png"),
pixmap);
pixmap.dispose();
}
示例2: PlayerAnimation
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public PlayerAnimation() {
nullRegion = new TextureRegion(new Texture(new Pixmap(1, 1, Pixmap.Format.RGBA8888)));
for (int i = 0; i < regions.length; i++) {
Pixmap pixmap = new Pixmap(64, 64, Pixmap.Format.RGBA8888);
pixmap.setColor(0, 0, 1, 1);
pixmap.fillCircle(32, 32, 10);
pixmap.setColor(1, 1, 1, 1);
pixmap.fillCircle(32, 32, 5);
pixmap.setColor(1, 1, 1, 0.5f);
pixmap.drawCircle(32, 32, (int) (i * 3f) + 7);
pixmap.setColor(1, 1, 1, 1f);
pixmap.drawCircle(32, 32, (int) (i * 3f) + 8);
pixmap.setColor(1, 1, 1, 0.5f);
pixmap.drawCircle(32, 32, (int) (i * 3f) + 9);
regions[i] = new TextureRegion(new Texture(pixmap));
pixmap.dispose();
}
setRegion(regions[0]);
}
示例3: createHighlightingGraphic
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
private Texture createHighlightingGraphic(TextureRegion textureRegion)
{
TextureData textureData = textureRegion.getTexture().getTextureData();
textureData.prepare();
Pixmap sourcePixmap = textureData.consumePixmap();
Pixmap destinationPixmap = new Pixmap(textureRegion.getRegionWidth(), textureRegion.getRegionHeight(), Format.RGBA8888);
Color color = new Color();
for (int x = 0; x < textureRegion.getRegionWidth(); x++)
{
for (int y = 0; y < textureRegion.getRegionHeight(); y++)
{
int colorInt = sourcePixmap.getPixel(textureRegion.getRegionX() + x, textureRegion.getRegionY() + y);
Color.rgba8888ToColor(color, colorInt);
destinationPixmap.setColor(1.0f, 1f, 1.0f, 1);
if (color.a > 0.004f)
destinationPixmap.drawPixel(x, y);
}
}
Texture result = new Texture(destinationPixmap);
textureData.disposePixmap();
destinationPixmap.dispose();
return result;
}
示例4: takeScreenshot
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public static void takeScreenshot() {
Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
FileHandle dir = Compatibility.get().getBaseFolder().child("screenshots");
dir.mkdirs();
FileHandle f = dir.child(System.currentTimeMillis() + ".png");
try {
PixmapIO.PNG writer = new PixmapIO.PNG((int) (pixmap.getWidth() * pixmap.getHeight() * 1.5f));
try {
writer.setFlipY(true);
writer.write(f, pixmap);
} finally {
writer.dispose();
}
} catch (IOException ex) {
throw new CubesException("Error writing PNG: " + f, ex);
} finally {
pixmap.dispose();
}
Log.info("Took screenshot '" + f.file().getAbsolutePath() + "'");
}
示例5: stencil
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
private void stencil(Planet planet, Texture texture, PlanetCell.CellType[] replaceTypes, int degrees, int x1, int y1) {
final TextureData textureData = texture.getTextureData();
textureData.prepare();
final Pixmap pixmap = textureData.consumePixmap();
for (int y = 0; y < texture.getHeight(); y++) {
for (int x = 0; x < texture.getWidth(); x++) {
tv.set(x, y).rotate(degrees).add(x1, y1);
int color = pixmap.getPixel(x, texture.getHeight() - y);
final PlanetCell.CellType type = getSourceCellType(planet, color);
if (type != null) {
replaceCell(planet, Math.round(tv.x), Math.round(tv.y), replaceTypes, type, color);
}
}
}
pixmap.dispose();
}
示例6: createMoonSprite
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public Sprite createMoonSprite(int size) {
Pixmap pixmap = new Pixmap(size, size, Pixmap.Format.RGBA8888);
// pixmap.setColor(color);
pixmap.setColor(Color.WHITE);
pixmap.fillCircle(pixmap.getWidth()/2, pixmap.getHeight()/2, size / 2 - 1);
Sprite sprite = new Sprite(new Texture(pixmap));
pixmap.dispose();
return sprite;
}
示例7: createSquare
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public Sprite createSquare(int size) {
Pixmap pixmap = new Pixmap(size, size, Pixmap.Format.RGBA8888);
// pixmap.setColor(color);
pixmap.setColor(Color.WHITE);
pixmap.fillRectangle(0, 0, size, size);
Sprite sprite = new Sprite(new Texture(pixmap));
pixmap.dispose();
return sprite;
}
示例8: TileTexture
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public TileTexture(int width, int height) {
Pixmap pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888);
pixmap.setColor(Color.LIGHT_GRAY);
pixmap.fillRectangle(0, 0, width, height);
pixmap.setColor(Color.WHITE);
pixmap.fillRectangle(1, 1, width - 2, height - 2);
texture = new Texture(pixmap);
pixmap.dispose();
}
示例9: generate
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
protected static void generate(FileHandle file, float strength) {
Pixmap blocks = new Pixmap(INDIVIDUAL_SIZE * 3, INDIVIDUAL_SIZE * 3, AOTextureGenerator.FORMAT);
Pixmap gaussian = new Pixmap(INDIVIDUAL_SIZE, INDIVIDUAL_SIZE, AOTextureGenerator.FORMAT);
Pixmap output = new Pixmap(TEXTURE_SIZE, TEXTURE_SIZE, AOTextureGenerator.FORMAT);
double[][] gwm = AOTextureGenerator.gaussianWeightMatrix(SIGMA);
int gaussianRadius = (gwm.length - 1) / 2;
Color blockColor = new Color(strength, strength, strength, 1f);
for (int i = 0; i < TOTAL; i++) {
String n = name(i);
System.out.print(n + " ");
AOTextureGenerator.clearPixmap(blocks);
AOTextureGenerator.clearPixmap(gaussian);
AOTextureGenerator.setupPixmap(blocks, i, blockColor);
AOTextureGenerator.gaussianPixmap(blocks, gaussian, gwm, gaussianRadius);
// PixmapIO.writePNG(folder.child(n + "_blocks_" + sigma + ".png"),
// blocks);
// PixmapIO.writePNG(folder.child(n + "_gaussian_" + sigma +
// ".png"), gaussian);
output.drawPixmap(gaussian, (i % SQRT_TOTAL) * INDIVIDUAL_SIZE, (i / SQRT_TOTAL) * INDIVIDUAL_SIZE, 0, 0,
INDIVIDUAL_SIZE, INDIVIDUAL_SIZE);
if (i % SQRT_TOTAL == SQRT_TOTAL - 1)
System.out.println();
}
PixmapIO.writePNG(file, output);
output.dispose();
blocks.dispose();
gaussian.dispose();
}
示例10: pick
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
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();
}
final Pixmap pixmap = td.consumePixmap();
int pixel = pixmap.getPixel(col * SIZE + x, row * SIZE + y);
pixmap.dispose();
return pixel;
}
示例11: getBlankTexture
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public static Texture getBlankTexture() {
final Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
pixmap.setColor(Color.WHITE);
pixmap.fill();
final Texture result = new Texture(pixmap);
pixmap.dispose();
return result;
}
示例12: blur
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
/**
* This is an implementation of a box blurring algorithm obtained from
* http://blackpawn.com/texts/blur/default.html
* @param img A pixmap which will be blurred
* @param radius The radius of the blur to generate to the image
* @return img, with a box blur of radius = r applied to it
*/
public static Pixmap blur(Pixmap img, int radius) {
Pixmap tmp = new Pixmap(img.getWidth(), img.getHeight(), Pixmap.Format.RGB888);
Pixmap result = new Pixmap(img.getWidth(), img.getHeight(), Pixmap.Format.RGB888);
blurHorizontal(img, tmp, radius);
blurVertical(tmp, result, radius);
tmp.dispose();
return result;
}
示例13: createCursorTexture
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
/**
* 創建文本框中的光標紋理
*/
private Texture createCursorTexture() {
Pixmap pixmap = new Pixmap(3, 10, Pixmap.Format.RGBA8888);
pixmap.setColor(0.047f, 0.047f, 0.047f, 1);
pixmap.fill();
Texture texture = new Texture(pixmap);
pixmap.dispose();
return texture;
}
示例14: createTextureFromBytes
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
/**
* Transforms byte[] to Texture Region.
* <p>
* If you are going to call this method inside firebase callback remember to wrap it<p>
* into {@code Gdx.app.postRunnable(Runnable)}.
* The texture will be changed so that it has sides with length of power of 2.
*
* @param bytes Byte array with image description
* @return Texture region representation of given byte array
*/
public static TextureRegion createTextureFromBytes(byte[] bytes)
{
Pixmap pixmap = new Pixmap(bytes, 0, bytes.length);
final int orgWidth = pixmap.getWidth();
final int orgHeight = pixmap.getHeight();
int width = MathUtils.nextPowerOfTwo(orgWidth);
int height = MathUtils.nextPowerOfTwo(orgHeight);
final Pixmap potPixmap = new Pixmap(width, height, pixmap.getFormat());
potPixmap.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight());
pixmap.dispose();
TextureRegion region = new TextureRegion(new Texture(potPixmap), 0, 0, orgWidth, orgHeight);
potPixmap.dispose();
return region;
}
示例15: generate
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
protected static void generate(FileHandle file, float strength) {
Pixmap blocks = new Pixmap(INDIVIDUAL_SIZE * 3, INDIVIDUAL_SIZE * 3, AOTextureGenerator.FORMAT);
Pixmap gaussian = new Pixmap(INDIVIDUAL_SIZE, INDIVIDUAL_SIZE, AOTextureGenerator.FORMAT);
Pixmap output = new Pixmap(TEXTURE_SIZE, TEXTURE_SIZE, AOTextureGenerator.FORMAT);
double[][] gwm = AOTextureGenerator.gaussianWeightMatrix(SIGMA);
int gaussianRadius = (gwm.length - 1) / 2;
Color blockColor = new Color(strength, strength, strength, 1f);
for (int i = 0; i < TOTAL; i++) {
String n = name(i);
System.out.print(n + " ");
AOTextureGenerator.clearPixmap(blocks);
AOTextureGenerator.clearPixmap(gaussian);
AOTextureGenerator.setupPixmap(blocks, i, blockColor);
AOTextureGenerator.gaussianPixmap(blocks, gaussian, gwm, gaussianRadius);
//PixmapIO.writePNG(folder.child(n + "_blocks_" + sigma + ".png"), blocks);
//PixmapIO.writePNG(folder.child(n + "_gaussian_" + sigma + ".png"), gaussian);
output.drawPixmap(gaussian, (i % SQRT_TOTAL) * INDIVIDUAL_SIZE, (i / SQRT_TOTAL) * INDIVIDUAL_SIZE, 0, 0, INDIVIDUAL_SIZE, INDIVIDUAL_SIZE);
if (i % SQRT_TOTAL == SQRT_TOTAL - 1) System.out.println();
}
PixmapIO.writePNG(file, output);
output.dispose();
blocks.dispose();
gaussian.dispose();
}