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


Java Pixmap.getWidth方法代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.Pixmap.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Pixmap.getWidth方法的具体用法?Java Pixmap.getWidth怎么用?Java Pixmap.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.graphics.Pixmap的用法示例。


在下文中一共展示了Pixmap.getWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fillFormWithConstantColor

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
public static Pixmap fillFormWithConstantColor(Pixmap pixmap, Color fillColor) {
    // set fill color
    pixmap.setColor(fillColor);

    Color color = new Color();

    for (int x = 0; x < pixmap.getWidth(); x++) {
        for (int y = 0; y < pixmap.getHeight(); y++) {
            int colorInt = pixmap.getPixel(x, y);
            color.set(colorInt);

            // get color alpha value
            float alpha = color.a;

            if (alpha > 0) {
                pixmap.setColor(fillColor);
                pixmap.fillRectangle(x, y, 1, 1);
            } else {
                pixmap.setColor(new Color(0, 0, 0, 0));
                pixmap.fillRectangle(x, y, 1, 1);
            }
        }
    }

    return pixmap;
}
 
开发者ID:opensourcegamedev,项目名称:SpaceChaos,代码行数:27,代码来源:PixmapUtils.java

示例2: 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_2,代码行数:22,代码来源:Graphics.java

示例3: 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

示例4: verifySize

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
private boolean verifySize(Pixmap pix){
	boolean w = false, h = false;
	for(int i : MapEditor.validMapSizes){
		if(pix.getWidth() == i)
			w = true;
		if(pix.getHeight() == i)
			h = true;
	}
	
	return w && h;
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:12,代码来源:MapEditorDialog.java

示例5: verifyMap

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
private boolean verifyMap(){
	int psc = ColorMapper.getColor(SpecialBlocks.playerSpawn);
	int esc = ColorMapper.getColor(SpecialBlocks.enemySpawn);
	
	int playerSpawns = 0;
	int enemySpawns = 0;
	Pixmap pix = editor.pixmap();
	
	for(int x = 0; x < pix.getWidth(); x ++){
		for(int y = 0; y < pix.getHeight(); y ++){
			int i = pix.getPixel(x, y);
			if(i == psc) playerSpawns ++;
			if(i == esc) enemySpawns ++;
		}
	}
	
	if(playerSpawns == 0){
		Vars.ui.showError("$text.editor.noplayerspawn");
		return false;
	}else if(playerSpawns > 1){
		Vars.ui.showError("$text.editor.manyplayerspawns");
		return false;
	}
	
	if(enemySpawns > MapEditor.maxSpawnpoints){
		Vars.ui.showError(Bundles.format("text.editor.manyenemyspawns", MapEditor.maxSpawnpoints));
		return false;
	}
	
	return true;
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:32,代码来源:MapEditorDialog.java

示例6: putPixelsBack

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
public static void putPixelsBack(Pixmap pixmap, ByteBuffer pixels) {
    if (pixmap.getWidth() == 0 || pixmap.getHeight() == 0) return;
    if (imageData == null) {
        imageData = pixmap.getContext().createImageData(pixmap.getHeight(), pixmap.getWidth());
    }
    putPixelsBack(pixels.array(), pixmap.getWidth(), pixmap.getHeight(), pixmap.getContext(), imageData);
}
 
开发者ID:DaanVanYperen,项目名称:odb-artax,代码行数:8,代码来源:MyScreenUtils.java

示例7: gaussianPixmap

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
private static void gaussianPixmap(Pixmap in, Pixmap out, double[][] gwm, int gaussianRadius) {
	Color inColor = new Color();
	Color outColor = new Color();

	int offsetX = (in.getWidth() - out.getWidth()) / 2;
	int offsetY = (in.getHeight() - out.getHeight()) / 2;

	int width = out.getWidth();
	int height = out.height();
	for (int x = 0; x < width; x++, width = out.getWidth()) {
		for (int y = 0; y < height; y++, height = out.height()) {
			outColor.set(0, 0, 0, 0);

			for (int ox = -gaussianRadius; ox <= gaussianRadius; ox++) {
				for (int oy = -gaussianRadius; oy <= gaussianRadius; oy++) {
					int pixel = in.getPixel(x + ox + offsetX, y + oy + offsetY);
					inColor.set(pixel);
					double d = gwm[ox + gaussianRadius][oy + gaussianRadius];
					outColor.r += inColor.r * d;
					outColor.g += inColor.g * d;
					outColor.b += inColor.b * d;
					outColor.a += inColor.a * d;
				}
			}

			out.drawPixel(x, y, Color.rgba8888(outColor.clamp()));
		}
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:30,代码来源:AOTextureGenerator.java

示例8: testRemovedPixmapField

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
public void testRemovedPixmapField(){
    GraphHeader.currentReadWriteVersion = 0;

    TestClass object = new TestClass();
    object.someInt = randInt();
    object.someFloat = randFloat();
    object.point = new GridPoint2(randInt(), randInt());
    object.color = new Color(Color.CYAN);
    object.smallTestClass = new SmallTestClass();
    object.smallTestClass.someValue = randInt();

    Pixmap pixmap = new Pixmap(20, 24, Pixmap.Format.RGBA8888);
    for (int i = 0; i < pixmap.getWidth(); i++) {
        for (int j = 0; j < pixmap.getHeight(); j++) {
            pixmap.drawPixel(i, j, randInt());
        }
    }
    object.smallTestClass.somePixmap = pixmap;

    kryo.register(SmallTestClass.class);
    kryo.register(TestClass.class);

    GraphHeader<TestClass> graphHeader = new GraphHeader<TestClass>();
    graphHeader.data = object;

    GraphHeader.currentReadWriteVersion = 0;
    byte[] written = write(graphHeader);

    GraphHeader.currentReadWriteVersion = 1;
    GraphHeader<TestClass> returned = read(written, GraphHeader.class);
    assertTrue(equals(graphHeader, returned));
    assertTrue(returned.data.smallTestClass.somePixmap == null);
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:34,代码来源:GraphHeaderTest.java

示例9: 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

示例10: blurHorizontal

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
private static void blurHorizontal(Pixmap src, Pixmap dst, int radius) {
    for (int i = 0; i < src.getWidth(); i++) {
        for (int j = 0; j < src.getHeight(); j++) {
            int r = 0;
            int g = 0;
            int b = 0;
            int count = 0;

            for (int x = i - radius; x <= i + radius; x++) {
                if (x < 0 || x > src.getWidth()) {
                    continue;
                }

                int current = src.getPixel(x, j) >> 8; // dump the alpha value
                b += (current & 0xff);
                current >>= 8;
                g += (current & 0xff);
                current >>= 8;
                r += (current & 0xff);

                count++;
            }

            r /= count;
            g /= count;
            b /= count;

            dst.drawPixel(i, j, getRGB(r, g, b));
        }
    }
}
 
开发者ID:treeman1111,项目名称:Particles,代码行数:32,代码来源:BoxBlur.java

示例11: blurVertical

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
private static void blurVertical(Pixmap src, Pixmap dst, int radius) {
    for (int i = 0; i < src.getWidth(); i++) {
        for (int j = 0; j < src.getHeight(); j++) {
            int r = 0;
            int g = 0;
            int b = 0;
            int count = 0;

            for (int y = j - radius; y <= j + radius; y++) {
                if (y < 0 || y >= src.getHeight()) {
                    continue;
                }

                int current = src.getPixel(i, y) >> 8; // no alpha needed
                b += (current & 0xff);
                current >>= 8;
                g += (current & 0xff);
                current >>= 8;
                r += (current & 0xff);

                count++;
            }

            r /= count;
            g /= count;
            b /= count;

            dst.drawPixel(i, j, getRGB(r, g, b));
        }
    }
}
 
开发者ID:treeman1111,项目名称:Particles,代码行数:32,代码来源:BoxBlur.java

示例12: 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

示例13: gaussianPixmap

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
private static void gaussianPixmap(Pixmap in, Pixmap out, double[][] gwm, int gaussianRadius) {
  Color inColor = new Color();
  Color outColor = new Color();

  int offsetX = (in.getWidth() - out.getWidth()) / 2;
  int offsetY = (in.getHeight() - out.getHeight()) / 2;

  for (int x = 0; x < out.getWidth(); x++) {
    for (int y = 0; y < out.getHeight(); y++) {
      outColor.set(0, 0, 0, 0);

      for (int ox = -gaussianRadius; ox <= gaussianRadius; ox++) {
        for (int oy = -gaussianRadius; oy <= gaussianRadius; oy++) {
          int pixel = in.getPixel(x + ox + offsetX, y + oy + offsetY);
          inColor.set(pixel);
          double d = gwm[ox + gaussianRadius][oy + gaussianRadius];
          outColor.r += inColor.r * d;
          outColor.g += inColor.g * d;
          outColor.b += inColor.b * d;
          outColor.a += inColor.a * d;
        }
      }

      out.drawPixel(x, y, Color.rgba8888(outColor.clamp()));
    }
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:28,代码来源:AOTextureGenerator.java

示例14: generate

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
/**Returns world size.*/
public static void generate(Pixmap pixmap, Tile[][] tiles){
	boolean hasenemies = true, hascore = false;
	
	Noise.setSeed(Vars.world.getSeed());
	
	for(int x = 0; x < pixmap.getWidth(); x ++){
		for(int y = 0; y < pixmap.getHeight(); y ++){
			Block floor = Blocks.stone;
			Block block = Blocks.air;
			
			int color = pixmap.getPixel(x, pixmap.getHeight()-1-y);
			BlockPair pair = ColorMapper.get(color);
			
			if(pair != null){
				block = pair.wall;
				floor = pair.floor;
			}
				
			if(block == SpecialBlocks.playerSpawn){
				block = Blocks.air;
				Vars.control.setCore(Vars.world.tile(x, y));
				hascore = true;
			}else if(block == SpecialBlocks.enemySpawn){
				block = Blocks.air;
				Vars.control.addSpawnPoint(Vars.world.tile(x, y));
				hasenemies = true;
			}
			
			if(block == Blocks.air && Mathf.chance(0.025) && rocks.containsKey(floor)){
				block = rocks.get(floor);
			}
			
			if(floor == Blocks.stone || floor == Blocks.grass || floor == Blocks.blackstone ||
					floor == Blocks.snow || floor == Blocks.sand){
				if(Noise.nnoise(x, y, 8, 1) > 0.21){
					floor = Blocks.iron;
				}
				
				if(Noise.nnoise(x, y, 6, 1) > 0.237){
					floor = Blocks.coal;
				}
				
				if(Noise.nnoise(x + 9999, y + 9999, 8, 1) > 0.27){
					floor = Blocks.titanium;
				}
				
				if(Noise.nnoise(x + 99999, y + 99999, 7, 1) > 0.259){
					floor = Blocks.uranium;
				}
			}
			
			if(color == Hue.rgb(Color.PURPLE)){
				if(!Vars.android) new Enemy(EnemyTypes.target).set(x * Vars.tilesize, y * Vars.tilesize).add();
				floor = Blocks.stone;
			}
			
			tiles[x][y].setBlock(block, 0);
			tiles[x][y].setFloor(floor);
		}
	}

	for(int x = 0; x < pixmap.getWidth(); x ++){
		for(int y = 0; y < pixmap.getHeight(); y ++) {
			tiles[x][y].updateOcclusion();
		}
	}
	
	if(!hascore){
		GameState.set(State.menu);
		Vars.ui.showError("[orange]Invalid map:[] this map has no core!");
	}
	
	if(!hasenemies){
		GameState.set(State.menu);
		Vars.ui.showError("[orange]Invalid map:[] this map has no enemy spawnpoints!");
	}
}
 
开发者ID:Anuken,项目名称:Mindustry,代码行数:79,代码来源:WorldGenerator.java

示例15: insertImage

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
public boolean insertImage(Asset asset, Pixmap image) {
	if (rectangles.containsKey(asset))
		throw new RuntimeException("Key \"" + asset.toString() + "\" is already in map");

	int borderPixels = padding;
	borderPixels <<= 1;
	PackRectangle rect = new PackRectangle(0, 0, image.getWidth() + borderPixels, image.getHeight() + borderPixels);
	Node node = insert(root, rect);

	if (node == null)
		return false;

	node.name = asset.toString();
	rect = new PackRectangle(node.rect);
	rect.width -= borderPixels;
	rect.height -= borderPixels;
	borderPixels >>= 1;
	rect.x += borderPixels;
	rect.y += borderPixels;
	rectangles.put(asset, rect);
	pixmap.drawPixmap(image, rect.x, rect.y);

	if (duplicateBorder) {
		pixmap.drawPixmap(image, rect.x, rect.y - 1, 0, 0, image.getWidth(), 1);
		pixmap.drawPixmap(image, rect.x, rect.y + image.getHeight(), 0, image.getHeight() - 1, image.getWidth(), 1);
		pixmap.drawPixmap(image, rect.x - 1, rect.y, 0, 0, 1, image.getHeight());
		pixmap.drawPixmap(image, rect.x + image.getWidth(), rect.y, image.getWidth() - 1, 0, 1, image.getHeight());

		pixmap.drawPixel(rect.x - 1, rect.y - 1, image.getPixel(0, 0));
		pixmap.drawPixel(rect.x + image.getWidth(), rect.y - 1, image.getPixel(image.getWidth() - 1, 0));
		pixmap.drawPixel(rect.x - 1, rect.y + image.getHeight(), image.getPixel(0, image.getHeight() - 1));
		pixmap.drawPixel(rect.x + image.getWidth(), rect.y + image.getHeight(),
				image.getPixel(image.getWidth() - 1, image.getHeight() - 1));

		// pixmap.drawPixmap(image, rect.x - 1, rect.y, rect.x, rect.y +
		// rect.height, 0, 0, 1, image.getHeight(), null);
		// pixmap.drawPixmap(image, rect.x + rect.width, rect.y, rect.x +
		// rect.width + 1, rect.y + rect.height, image.getWidth() - 1, 0);

		// pixmap.drawPixmap(image, rect.x - 1, rect.y - 1, rect.x, rect.y,
		// 0, 0);
		// pixmap.drawPixmap(image, rect.x + rect.width, rect.y - 1, rect.x
		// + rect.width + 1, rect.y, image.getWidth() - 1, 0);

		// pixmap.drawPixmap(image, rect.x - 1, rect.y + rect.height,
		// rect.x, rect.y + rect.height + 1, 0, image.getHeight() - 1);
		// pixmap.drawPixmap(image, rect.x + rect.width, rect.y +
		// rect.height, rect.x + rect.width + 1, rect.y + rect.height + 1
		// image.getWidth() - 1, image.getHeight() - 1);
	}

	return true;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:54,代码来源:TexturePacker.java


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