當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。