当前位置: 首页>>代码示例>>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;未经允许,请勿转载。