當前位置: 首頁>>代碼示例>>Java>>正文


Java Pixmap類代碼示例

本文整理匯總了Java中com.badlogic.gdx.graphics.Pixmap的典型用法代碼示例。如果您正苦於以下問題:Java Pixmap類的具體用法?Java Pixmap怎麽用?Java Pixmap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Pixmap類屬於com.badlogic.gdx.graphics包,在下文中一共展示了Pixmap類的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: writePixmaps

import com.badlogic.gdx.graphics.Pixmap; //導入依賴的package包/類
/** A utility method to write the given array of pixmaps to the given output directory, with the specified file name. If the
 * pages array is of length 1, then the resulting file ref will look like: "fileName.png".
 *
 * If the pages array is greater than length 1, the resulting file refs will be appended with "_N", such as "fileName_0.png",
 * "fileName_1.png", "fileName_2.png" etc.
 *
 * The returned string array can then be passed to the <tt>writeFont</tt> method.
 *
 * Note: None of the pixmaps will be disposed.
 *
 * @param pages the pages of pixmap data to write
 * @param outputDir the output directory
 * @param fileName the file names for the output images
 * @return the array of string references to be used with <tt>writeFont</tt> */
public static String[] writePixmaps (Pixmap[] pages, FileHandle outputDir, String fileName) {
  if (pages == null || pages.length == 0) throw new IllegalArgumentException("no pixmaps supplied to BitmapFontWriter.write");
  
  String[] pageRefs = new String[pages.length];
  
  for (int i = 0; i < pages.length; i++) {
    String ref = pages.length == 1 ? (fileName + ".png") : (fileName + "_" + i + ".png");
    
    // the ref for this image
    pageRefs[i] = ref;
    
    // write the PNG in that directory
    PixmapIO.writePNG(outputDir.child(ref), pages[i]);
  }
  return pageRefs;
}
 
開發者ID:RedTroop,項目名稱:Cubes,代碼行數:31,代碼來源:BitmapFontWriter.java

示例3: createToolTip

import com.badlogic.gdx.graphics.Pixmap; //導入依賴的package包/類
private void createToolTip()
{
	Skin skin = new Skin();
	Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
	pixmap.setColor(Color.WHITE);
	pixmap.fill();
	skin.add("white", new Texture(pixmap));
	skin.add("default", new BitmapFont());

	TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
	textButtonStyle.up = skin.newDrawable("white", new Color(0, 0, 0, 1));
	textButtonStyle.font = skin.getFont("default");
	skin.add("default", textButtonStyle);

	labelToolTip = new TextButton("TEST", skin);
	labelToolTip.setX(5);
	labelToolTip.setY(5);
	labelToolTip.setWidth(125);
	labelToolTip.setVisible(false);
	labelToolTip.getLabel().setWrap(true);
	labelToolTip.setHeight(labelToolTip.getLabel().getHeight());
	group.addActor(labelToolTip);
}
 
開發者ID:MartensCedric,項目名稱:LD38-Compo,代碼行數:24,代碼來源:LudumDare38.java

示例4: createResetButton

import com.badlogic.gdx.graphics.Pixmap; //導入依賴的package包/類
private void createResetButton()
{
	Skin skin = new Skin();
	Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
	pixmap.setColor(Color.WHITE);
	pixmap.fill();
	skin.add("white", new Texture(pixmap));
	skin.add("default", new BitmapFont());

	TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
	textButtonStyle.up = skin.newDrawable("white", new Color(0, 0, 0, 1));
	textButtonStyle.font = skin.getFont("default");
	skin.add("default", textButtonStyle);

	btnReset = new TextButton("RESET", skin);
	btnReset.setX(5);
	btnReset.setY(Gdx.graphics.getHeight() - 25);
	btnReset.setWidth(60);
	btnReset.setVisible(true);
	group.addActor(btnReset);
}
 
開發者ID:MartensCedric,項目名稱:LD38-Compo,代碼行數:22,代碼來源:LudumDare38.java

示例5: createUndoButton

import com.badlogic.gdx.graphics.Pixmap; //導入依賴的package包/類
private void createUndoButton()
{
	Skin skin = new Skin();
	Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
	pixmap.setColor(Color.WHITE);
	pixmap.fill();
	skin.add("white", new Texture(pixmap));
	skin.add("default", new BitmapFont());

	TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
	textButtonStyle.up = skin.newDrawable("white", new Color(0, 0, 0, 1));
	textButtonStyle.font = skin.getFont("default");
	skin.add("default", textButtonStyle);

	btnUndo = new TextButton("UNDO", skin);
	btnUndo.setX(70);
	btnUndo.setY(Gdx.graphics.getHeight() - 25);
	btnUndo.setWidth(60);
	btnUndo.setVisible(true);
	group.addActor(btnUndo);
}
 
開發者ID:MartensCedric,項目名稱:LD38-Compo,代碼行數:22,代碼來源:LudumDare38.java

示例6: setColor

import com.badlogic.gdx.graphics.Pixmap; //導入依賴的package包/類
public void setColor(int color) {
    Pixmap pix = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
    pix.setColor(color);
    pix.fill();
    Texture tex = new Texture(pix);
    TextureRegion region = new TextureRegion(tex);

    Point p1 = (Point) parent.getPoints().toArray()[0];
    Point p2 = (Point) parent.getPoints().toArray()[1];
    Point p3 = (Point) parent.getPoints().toArray()[2];
    Point p4 = (Point) parent.getPoints().toArray()[3];
    Point p5 = (Point) parent.getPoints().toArray()[4];
    Point p6 = (Point) parent.getPoints().toArray()[5];

    float[] vertices = new float[]{(
            float) p1.getCoordinateX(), (float)p1.getCoordinateY(),
            (float)p2.getCoordinateX(), (float)p2.getCoordinateY(),
            (float)p3.getCoordinateX(), (float)p3.getCoordinateY(),
            (float) p4.getCoordinateX(), (float)p4.getCoordinateY(),
            (float)p5.getCoordinateX(), (float)p5.getCoordinateY(),
            (float)p6.getCoordinateX(), (float)p6.getCoordinateY()};
    EarClippingTriangulator triangulator = new EarClippingTriangulator();
    ShortArray triangleIndices = triangulator.computeTriangles(vertices);
    PolygonRegion polygonRegion = new PolygonRegion(region, vertices, triangleIndices.toArray());
    sprite = new PolygonSprite(polygonRegion);
}
 
開發者ID:MartensCedric,項目名稱:LD38-Compo,代碼行數:27,代碼來源:TileData.java

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

示例8: initialize

import com.badlogic.gdx.graphics.Pixmap; //導入依賴的package包/類
/**
 * Initializes the pattern table textures and pixmap.
 */
public void initialize() {
    //Allocate a pixmap big enough to accommodate both pattern tables.
    patternTablePixmap = new Pixmap(128, 256, Pixmap.Format.RGBA8888);
    //Set blending to none so we can rewrite the pixmap and draw it to the
    //pattern table texture when graphics are regenerated.
    patternTablePixmap.setBlending(Pixmap.Blending.None);

    //Allocate a pixmap the size of one tile for live CHR-RAM updates.
    patternPixmap = new Pixmap(8, 8, Pixmap.Format.RGBA8888);
    patternPixmap.setBlending(Pixmap.Blending.None);

    patternTableTexture = new Texture(patternTablePixmap, false);
    TextureRegion[][] textureRegions = TextureRegion.split(patternTableTexture, 8, 8);
    patternTableSprites = new Sprite[32][16];
    for(int row = 0; row < 32; row++) {
        for(int column = 0; column < 16; column++) {
            TextureRegion textureRegion = textureRegions[row][column];
            patternTableSprites[row][column] = new Sprite(textureRegion);
        }
    }
    initializeMonochromePalette();
}
 
開發者ID:gradualgames,項目名稱:ggvm,代碼行數:26,代碼來源:PatternTableManager.java

示例9: saveAndReload

import com.badlogic.gdx.graphics.Pixmap; //導入依賴的package包/類
public void saveAndReload(Map map, Pixmap out){
	if(map.pixmap != null && out != map.pixmap && map.texture != null){
		map.texture.dispose();
		map.texture = new Texture(out);
	}else if (out == map.pixmap){
		map.texture.draw(out, 0, 0);
	}
	
	map.pixmap = out;
	if(map.texture == null) map.texture = new Texture(map.pixmap);
	
	if(map.id == -1){
		if(mapNames.containsKey(map.name)){
			map.id = mapNames.get(map.name).id;
		}else{
			map.id = ++lastID;
		}
	}
	
	if(!Settings.has("hiscore" + map.name)){
		Settings.defaults("hiscore" + map.name, 0);
	}
	
	saveCustomMap(map);
	Vars.ui.levels.reload();
}
 
開發者ID:Anuken,項目名稱:Mindustry,代碼行數:27,代碼來源:Maps.java

示例10: loadMapFile

import com.badlogic.gdx.graphics.Pixmap; //導入依賴的package包/類
private boolean loadMapFile(FileHandle file){
	try{
		Array<Map> arr = json.fromJson(ArrayContainer.class, file).maps;
		if(arr != null){ //can be an empty map file
			for(Map map : arr){
				map.pixmap = new Pixmap(file.sibling(map.name + ".png"));
				map.texture = new Texture(map.pixmap);
				maps.put(map.id, map);
				mapNames.put(map.name, map);
				lastID = Math.max(lastID, map.id);
			}
		}
		return true;
	}catch(Exception e){
		if(!Vars.android) e.printStackTrace();
		Gdx.app.error("Mindustry-Maps", "Failed loading map file: " + file);
		return false;
	}
}
 
開發者ID:Anuken,項目名稱:Mindustry,代碼行數:20,代碼來源:Maps.java

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

示例12: draw

import com.badlogic.gdx.graphics.Pixmap; //導入依賴的package包/類
public void draw(Coordinates<Integer> coords, Pixmap map) {
	int terrainID = world.get(coords.y).get(coords.x);
	
	// tileID runs 0 through 8, conveniently in the
	// same order as our split tiles texture...
	int ty = (int) terrainID / 3;
	int tx = terrainID % 3;

	TextureRegion tileRegion = tileRegions[ty][tx];

	map.drawPixmap(tilesPixmap,
				   coords.x * tileSize,
				   coords.y * tileSize,
				   tileRegion.getRegionX(),
				   tileRegion.getRegionY(),
				   tileRegion.getRegionWidth(),
				   tileRegion.getRegionHeight());
}
 
開發者ID:mcgeer,項目名稱:Climatar,代碼行數:19,代碼來源:DrawableMap.java

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

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

示例15: VRCamera

import com.badlogic.gdx.graphics.Pixmap; //導入依賴的package包/類
public VRCamera(int width, int height, int viewportWidth, int viewportHeight) {
    leftCamera = new PerspectiveCamera(90, viewportWidth, viewportHeight);
    rightCamera = new PerspectiveCamera(90, viewportWidth, viewportHeight);
    leftBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, true);
    rightBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, true);
    leftTexture = new TextureRegion();
    rightTexture = new TextureRegion();
    batch = new SpriteBatch();
    this.width = width;
    this.height = height;
    this.viewportWidth = viewportWidth;
    this.viewportHeight = viewportHeight;
    tmpVector3 = new Vector3();
    position = new Vector3(250, 20, 250);
    positionLeft = new Vector3(249.5f, 20, 250);
    positionRight = new Vector3(250.5f, 20, 250);
    direction = new Vector3();
    up = new Vector3(0, 1, 0);
    eyeDistance = 0.5f;
}
 
開發者ID:justinmarentette11,項目名稱:Tower-Defense-Galaxy,代碼行數:21,代碼來源:VRCamera.java


注:本文中的com.badlogic.gdx.graphics.Pixmap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。