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


Java Pixmap.getPixel方法代码示例

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


在下文中一共展示了Pixmap.getPixel方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: TileTouchCheck

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
private TileTouchCheck(Pixmap pixelMap, TextureRegion region) {
	this.width = region.getRegionWidth();
	this.height = region.getRegionHeight();
	map = new int[width * height];
	int i = -1;
	// pixmap coordinates have the origin in the top left corner; shift it so it goes from the bottom left instead
	for (int x = 0; x < width; x++) {
		for (int y = height-1; y >= 0; y--) {
			Color color = new Color(pixelMap.getPixel(region.getRegionX() + x, region.getRegionY() + y));
			
			i++;
			if(color.a == 0) continue; // set to zero, tile doesn't matter
			
			if(color.equals(Color.WHITE)) // the tile must be different from the center tile
				map[i] = WHITE;
			else if(color.equals(Color.BLACK)) // the tile must be equal to the center tile
				map[i] = BLACK;
		}
	}
}
 
开发者ID:chrisj42,项目名称:miniventure,代码行数:21,代码来源:TileTouchCheck.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: 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

示例5: MapManager

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
public MapManager(Texture map){
    bkgnd = SpriteSheet.background;
    width = map.getWidth();
    height = map.getHeight();
    tiles = new short[width * height];
    if(!map.getTextureData().isPrepared())
        map.getTextureData().prepare();
    Pixmap p = map.getTextureData().consumePixmap();
    for(int y = 0; y < height; y++) {
        for(int x = 0; x < width; x++) {
            if(p.getPixel(x,y) == Tile.GRASS_COL) tiles[x + ((height - y - 1) * width)] = Tile.GRASS_ID;
            if(p.getPixel(x,y) == Tile.DIRT_COL) tiles[x + ((height - y - 1) * width)] = Tile.DIRT_ID;
            if(p.getPixel(x,y) == Tile.SAND_COL) tiles[x + ((height - y - 1) * width)] = Tile.SAND_ID;
            if(p.getPixel(x,y) == Tile.WATER_COL) tiles[x + ((height - y - 1) * width)] = Tile.WATER_ID;

        }
    }
}
 
开发者ID:elitej13,项目名称:project-divine-intervention,代码行数:19,代码来源:MapManager.java

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

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

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

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

示例11: colorNotMatch

import com.badlogic.gdx.graphics.Pixmap; //导入方法依赖的package包/类
private boolean colorNotMatch(Pixmap pixmap, int x, int y, int color)
{
    int pixel = pixmap.getPixel(x, y);
    if ((pixel & 0xFF) == 0)
    {
        return color != 0;
    }
    return pixel != color;
}
 
开发者ID:kurtyu,项目名称:PixelDungeonTC,代码行数:10,代码来源:BitmapText.java

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

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


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