当前位置: 首页>>代码示例>>Java>>正文


Java Pixmap.dispose方法代码示例

本文整理汇总了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();
}
 
开发者ID:eskalon,项目名称:ProjektGG,代码行数:18,代码来源:ScreenshotUtils.java

示例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]);
}
 
开发者ID:cn-s3bit,项目名称:TH902,代码行数:20,代码来源:Player.java

示例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;
}
 
开发者ID:MMORPG-Prototype,项目名称:MMORPG_Prototype,代码行数:25,代码来源:GameObjectHighlightGraphic.java

示例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() + "'");
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:21,代码来源:Graphics.java

示例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();
}
 
开发者ID:DaanVanYperen,项目名称:odb-little-fortune-planet,代码行数:21,代码来源:PlanetStencilSystem.java

示例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;
    }
 
开发者ID:ZKasica,项目名称:Planet-Generator,代码行数:10,代码来源:ObjectGenerator.java

示例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;
    }
 
开发者ID:ZKasica,项目名称:Planet-Generator,代码行数:10,代码来源:ObjectGenerator.java

示例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();
}
 
开发者ID:conquest,项目名称:conquest,代码行数:13,代码来源:Assets.java

示例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();
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:40,代码来源:AOTextureGenerator.java

示例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;
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:16,代码来源:ItemSprite.java

示例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;
}
 
开发者ID:LonamiWebs,项目名称:Klooni1010,代码行数:9,代码来源:Theme.java

示例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;
}
 
开发者ID:treeman1111,项目名称:Particles,代码行数:18,代码来源:BoxBlur.java

示例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;
}
 
开发者ID:heyzqt,项目名称:libGdx-xiyou,代码行数:12,代码来源:InputnameDialog.java

示例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;
}
 
开发者ID:mk-5,项目名称:gdx-fireapp,代码行数:25,代码来源:ImageHelper.java

示例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();
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:36,代码来源:AOTextureGenerator.java


注:本文中的com.badlogic.gdx.graphics.Pixmap.dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。