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


Java ScreenUtils类代码示例

本文整理汇总了Java中com.badlogic.gdx.utils.ScreenUtils的典型用法代码示例。如果您正苦于以下问题:Java ScreenUtils类的具体用法?Java ScreenUtils怎么用?Java ScreenUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: takeScreenshot

import com.badlogic.gdx.utils.ScreenUtils; //导入依赖的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: takeScreenshot

import com.badlogic.gdx.utils.ScreenUtils; //导入依赖的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.utils.ScreenUtils; //导入依赖的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: getScreenshot

import com.badlogic.gdx.utils.ScreenUtils; //导入依赖的package包/类
private static Pixmap getScreenshot (int x, int y, int w, int h, boolean yDown) {
	final Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(x, y, w, h);

	if (yDown) {
		// Flip the pixmap upside down
		ByteBuffer pixels = pixmap.getPixels();
		int numBytes = w * h * 4;
		byte[] lines = new byte[numBytes];
		int numBytesPerLine = w * 4;
		for (int i = 0; i < h; i++) {
			pixels.position((h - i - 1) * numBytesPerLine);
			pixels.get(lines, i * numBytesPerLine, numBytesPerLine);
		}
		pixels.clear();
		pixels.put(lines);
	}

	return pixmap;
}
 
开发者ID:unlimitedggames,项目名称:gdxjam-ugg,代码行数:20,代码来源:ScreenshotFactory.java

示例5: getScreenshot

import com.badlogic.gdx.utils.ScreenUtils; //导入依赖的package包/类
private static Pixmap getScreenshot(final int x, final int y, final int w, final int h, final boolean yDown)
{

    final Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(x, y, w, h);

    if (yDown)
    {
        // Flip the pixmap upside down
        final ByteBuffer pixels = pixmap.getPixels();
        final int numBytes = w * h * 4;
        final byte[] lines = new byte[numBytes];
        final int numBytesPerLine = w * 4;
        for (int i = 0; i < h; i++)
        {
            pixels.position((h - i - 1) * numBytesPerLine);
            pixels.get(lines, i * numBytesPerLine, numBytesPerLine);
        }
        pixels.clear();
        pixels.put(lines);
    }

    return pixmap;
}
 
开发者ID:ncguy2,项目名称:Argent,代码行数:24,代码来源:ScreenshotFactory.java

示例6: renderScreenshot

import com.badlogic.gdx.utils.ScreenUtils; //导入依赖的package包/类
@Override
public void renderScreenshot(IWritableScreenshot ss, Rect glRect) {
    final ITextureData texData;
    if (ss.isVolatile()) {
        TextureRegion textureRegion = ScreenUtils.getFrameBufferTexture(glRect.x, glRect.y, glRect.w, glRect.h);
        GdxTextureUtil.setDefaultTextureParams(textureRegion.getTexture());
        textureRegion.flip(false, true);
        texData = VolatileTextureData.fromRegion(textureRegion, false);
    } else {
        Pixmap pixels = GdxScreenshotUtil.screenshot(glRect);
        texData = PixelTextureData.fromPremultipliedPixmap(pixels);
    }

    Rect glSize = renderEnv.getGLClip();
    ss.setPixels(texData, Dim.of(glSize.w, glSize.h));
}
 
开发者ID:anonl,项目名称:nvlist,代码行数:17,代码来源:GLScreenRenderer.java

示例7: screenshot

import com.badlogic.gdx.utils.ScreenUtils; //导入依赖的package包/类
public void screenshot(String filename) {
	if (fbo != null) {
		FileHandle local = Gdx.files.local(filename);
		try {
			FileHandle fh;
			do {
				fh = local;
			} while (fh.exists());
			byte[] frameBufferPixels = ScreenUtils.getFrameBufferPixels(0, 0, G.CANVAS_WIDTH, G.CANVAS_HEIGHT, true);
			Pixmap pixmap = new Pixmap(G.CANVAS_WIDTH, G.CANVAS_HEIGHT, Pixmap.Format.RGBA8888);
			pixmap.getPixels().put(frameBufferPixels);
			PixmapIO.writePNG(fh, pixmap);
			pixmap.dispose();

			fbo.end();
			fbo.dispose();

		} catch (Exception e) {
		}
	}
}
 
开发者ID:DaanVanYperen,项目名称:ns2-scc-profiler,代码行数:22,代码来源:ScreenshotHelper.java

示例8: getScreenshot

import com.badlogic.gdx.utils.ScreenUtils; //导入依赖的package包/类
private static Pixmap getScreenshot(int x, int y, int w, int h, boolean yDown){
  final Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(x, y, w, h);

  if (yDown) {
    // Flip the pixmap upside down
    ByteBuffer pixels = pixmap.getPixels();
    int numBytes = w * h * 4;
    byte[] lines = new byte[numBytes];
    int numBytesPerLine = w * 4;
    for (int i = 0; i < h; i++) {
      pixels.position((h - i - 1) * numBytesPerLine);
      pixels.get(lines, i * numBytesPerLine, numBytesPerLine);
    }
    pixels.clear();
    pixels.put(lines);
  }

  return pixmap;
}
 
开发者ID:macbury,项目名称:ForgE,代码行数:20,代码来源:ScreenshotFactory.java

示例9: render

import com.badlogic.gdx.utils.ScreenUtils; //导入依赖的package包/类
public void render () {
	Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	batch.begin();
	if (screenshot == null) {
		int width = Gdx.graphics.getWidth(), height = Gdx.graphics.getHeight();
		for (int i = 0; i < 100; i++)
			batch.draw(badlogic, MathUtils.random(width), MathUtils.random(height));
		batch.flush();

		FileHandle file = FileHandle.tempFile("screenshot-");
		System.out.println(file.file().getAbsolutePath());
		Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
		try {
			PNG writer = new PNG((int)(pixmap.getWidth() * pixmap.getHeight() * 1.5f));
			// writer.setCompression(Deflater.NO_COMPRESSION);
			writer.write(file, pixmap);
			writer.dispose();
		} catch (IOException ex) {
			throw new RuntimeException(ex);
		}
		screenshot = new Texture(file);
	}
	batch.draw(screenshot, 0, 0);
	batch.end();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:26,代码来源:PngTest.java

示例10: getScreenshot

import com.badlogic.gdx.utils.ScreenUtils; //导入依赖的package包/类
private static Pixmap getScreenshot(int x, int y, int w, int h, boolean yDown){
    final Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(x, y, w, h);

    if (yDown) {
        // Flip the pixmap upside down
        ByteBuffer pixels = pixmap.getPixels();
        int numBytes = w * h * 4;
        byte[] lines = new byte[numBytes];
        int numBytesPerLine = w * 4;
        for (int i = 0; i < h; i++) {
            pixels.position((h - i - 1) * numBytesPerLine);
            pixels.get(lines, i * numBytesPerLine, numBytesPerLine);
        }
        pixels.clear();
        pixels.put(lines);
    }

    return pixmap;
}
 
开发者ID:pierotofy,项目名称:snappyfrog,代码行数:20,代码来源:ScreenshotFactory.java

示例11: getScreenshot

import com.badlogic.gdx.utils.ScreenUtils; //导入依赖的package包/类
private static Pixmap getScreenshot(int x, int y, int w, int h, boolean yDown) {
	final Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(x, y, w, h);
	
	if (yDown) {
		// Flip the pixmap upside down
		ByteBuffer pixels = pixmap.getPixels();
		int numBytes = w * h * 4;
		byte[] lines = new byte[numBytes];
		int numBytesPerLine = w * 4;
		for (int i = 0; i < h; i++) {
			pixels.position((h - i - 1) * numBytesPerLine);
			pixels.get(lines, i * numBytesPerLine, numBytesPerLine);
		}
		pixels.clear();
		pixels.put(lines);
	}
	
	return pixmap;
}
 
开发者ID:Dakror,项目名称:Vloxlands,代码行数:20,代码来源:Vloxlands.java

示例12: getScreenshot

import com.badlogic.gdx.utils.ScreenUtils; //导入依赖的package包/类
public static Pixmap getScreenshot(int x, int y, int w, int h, boolean yDown){
    final Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(x, y, w, h);

    if (yDown) {
        // Flip the pixmap upside down
        ByteBuffer pixels = pixmap.getPixels();
        int numBytes = w * h * 4;
        byte[] lines = new byte[numBytes];
        int numBytesPerLine = w * 4;
        for (int i = 0; i < h; i++) {
            pixels.position((h - i - 1) * numBytesPerLine);
            pixels.get(lines, i * numBytesPerLine, numBytesPerLine);
        }
        pixels.clear();
        pixels.put(lines);
    }

    return pixmap;
}
 
开发者ID:chrislo27,项目名称:Stray-core,代码行数:20,代码来源:ScreenshotFactory.java

示例13: show

import com.badlogic.gdx.utils.ScreenUtils; //导入依赖的package包/类
/**
 * Initializes the mesh with the pixels of the given group.
 * 
 * The result vectors must be in {@link #scaledView} coordinates.
 * 
 * @param toEdit
 * @param resultOrigin
 * @param resultSize
 */
public void show(Group toEdit, Vector2 resultOrigin, Vector2 resultSize) {
	int x = MathUtils.round(resultOrigin.x), y = MathUtils
			.round(resultOrigin.y), width = (int) resultSize.x, height = (int) resultSize.y;
	minX = x;
	minY = y;
	maxX = minX + width;
	maxY = minY + height;

	scaledView.localToStageCoordinates(temp.set(x, y));
	int stageX = MathUtils.round(temp.x), stageY = MathUtils.round(temp.y);

	Batch batch = controller.getPlatform().getBatch();
	batch.setProjectionMatrix(combinedMatrix);
	fbo.begin();
	batch.begin();
	toEdit.draw(batch, 1f);
	batch.end();
	currModifiedPixmap = new PixmapRegion(ScreenUtils.getFrameBufferPixmap(
			stageX, stageY, width, height), stageX, stageY);
	fbo.end();
}
 
开发者ID:e-ucm,项目名称:ead,代码行数:31,代码来源:MeshHelper.java

示例14: getMapScreenShot

import com.badlogic.gdx.utils.ScreenUtils; //导入依赖的package包/类
public Pixmap getMapScreenShot()
{

    float oldCameraZoom = getCamera().zoom;
    float oldCameraX = getCamera().position.x;
    float oldCameraY = getCamera().position.y;

    MapUtils.adjustCamera(getCamera(), grid);

    final FrameBuffer fbo = new FrameBuffer(Pixmap.Format.RGBA8888, WIDTH, HEIGHT, false);

    fbo.begin();
    batch.setProjectionMatrix(getCamera().combined);
    batch.begin();

    for(int i = 0; i < grid.getHexs().length; i++)
    {
        drawHexagon(grid.getHexs()[i], batch);
    }

    batch.end();
    Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, WIDTH, HEIGHT);
    fbo.end();

    //fbo.dispose();

    getCamera().zoom = oldCameraZoom;
    getCamera().position.x = oldCameraX;
    getCamera().position.y = oldCameraY;

    return pixmap;
}
 
开发者ID:MartensCedric,项目名称:Hexpert,代码行数:33,代码来源:PlayScreen.java

示例15: takeScreenshot

import com.badlogic.gdx.utils.ScreenUtils; //导入依赖的package包/类
/**
 * Takes a screenshot of the current game state and saves it in the assets directory
 */
public 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);
	PixmapIO.writePNG(Gdx.files.local("screenshots/screenshot.png"), pixmap);
	pixmap.dispose();
}
 
开发者ID:johannesmols,项目名称:GangsterSquirrel,代码行数:11,代码来源:MainGameClass.java


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