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


Java ScreenUtils.getFrameBufferPixels方法代码示例

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


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

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

示例4: takeScreenShot

import com.badlogic.gdx.utils.ScreenUtils; //导入方法依赖的package包/类
public static void takeScreenShot(final String filePath) {
    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.external(filePath), pixmap);
    pixmap.dispose();
}
 
开发者ID:JayStGelais,项目名称:jrpg-engine,代码行数:13,代码来源:ScreenShotUtil.java

示例5: takeScreenshot

import com.badlogic.gdx.utils.ScreenUtils; //导入方法依赖的package包/类
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.external(UUID.randomUUID().toString() + ".png"), pixmap);
    pixmap.dispose();
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:10,代码来源:MainCamera.java

示例6: saveChallengeImage

import com.badlogic.gdx.utils.ScreenUtils; //导入方法依赖的package包/类
public boolean saveChallengeImage(final int score, final boolean timeMode) {
    final File saveAt = getShareImageFilePath();
    if (!saveAt.getParentFile().isDirectory())
        if (!saveAt.mkdirs())
            return false;

    final FileHandle output = new FileHandle(saveAt);

    final Texture shareBase = new Texture(Gdx.files.internal("share.png"));
    final int width = shareBase.getWidth();
    final int height = shareBase.getHeight();

    final FrameBuffer frameBuffer = new FrameBuffer(Pixmap.Format.RGB888, width, height, false);
    frameBuffer.begin();

    // Render the base share texture
    final SpriteBatch batch = new SpriteBatch();
    final Matrix4 matrix = new Matrix4();
    matrix.setToOrtho2D(0, 0, width, height);
    batch.setProjectionMatrix(matrix);

    Gdx.gl.glClearColor(Color.GOLD.r, Color.GOLD.g, Color.GOLD.b, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.begin();
    batch.draw(shareBase, 0, 0);

    // Render the achieved score
    final Label.LabelStyle style = new Label.LabelStyle();
    style.font = new BitmapFont(Gdx.files.internal("font/x1.0/geosans-light64.fnt"));
    Label label = new Label("just scored " + score + " on", style);
    label.setColor(Color.BLACK);
    label.setPosition(40, 500);
    label.draw(batch, 1);

    label.setText("try to beat me if you can");
    label.setPosition(40, 40);
    label.draw(batch, 1);

    if (timeMode) {
        Texture timeModeTexture = new Texture("ui/x1.5/stopwatch.png");
        batch.setColor(Color.BLACK);
        batch.draw(timeModeTexture, 200, 340);
    }

    batch.end();

    // Get the framebuffer pixels and write them to a local file
    final byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0, width, height, true);

    final Pixmap pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888);

    BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length);
    PixmapIO.writePNG(output, pixmap);

    // Dispose everything
    pixmap.dispose();
    shareBase.dispose();
    batch.dispose();
    frameBuffer.end();

    return true;
}
 
开发者ID:LonamiWebs,项目名称:Klooni1010,代码行数:64,代码来源:ShareChallenge.java

示例7: generate

import com.badlogic.gdx.utils.ScreenUtils; //导入方法依赖的package包/类
/**
 * Returns an UNMANAGED texture that of the supplied size that
 * contains a map of the supplied game map.
 * 
 * @param map
 * @param gameState
 * @param width
 * @param height
 * @return
 */
public static Texture generate(GameMap map, GameState gameState, int width, int height) {

	boolean isIsometric = map.isIsometric();
	GameMapRenderer renderer = isIsometric ? new IsometricMinimapRenderer(gameState, map) : new OrthogonalMinimapRenderer(gameState, map);
	
	FrameBuffer fb = new FrameBuffer(Format.RGB565, width, height, false);
	float cameraWidth = map.getWidth();
	float cameraHeight = map.getHeight();
	if (isIsometric) {
		cameraWidth = cameraHeight = (float)(Math.sqrt(cameraWidth*cameraWidth + cameraHeight*cameraHeight) * Math.sqrt(2));
		cameraHeight /= 2;
	}
	
	float cameraPositionX = cameraWidth / 2;
	float cameraPositionY = isIsometric ? 0 : cameraHeight / 2;
	
	int tileSizeX = (int) map.getTileSizeX();
	int tileSizeY = (int) map.getTileSizeY();
	if (cameraWidth * tileSizeX < width || cameraHeight * tileSizeY < height) {
		cameraWidth = (float) width / tileSizeX;
		cameraHeight = (float) height / tileSizeY;
	}
       OrthographicCamera camera = new OrthographicCamera(cameraWidth, cameraHeight);
       camera.position.x = cameraPositionX;
       camera.position.y = cameraPositionY;
       camera.update();
	
	fb.begin();
	Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
	Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT);
	renderer.render(0, camera);
	byte[] bytes = ScreenUtils.getFrameBufferPixels(0, 0, width, height, true);
	fb.end();
	
	fb.dispose();
	renderer.dispose();
	
	Pixmap pixmap = new Pixmap(width, height, Format.RGBA8888);
	ByteBuffer pixels = pixmap.getPixels();
	pixels.clear();
	pixels.put(bytes);
	pixels.position(0);
	
	Texture returnValue = new Texture(pixmap);
	pixmap.dispose();
	return returnValue;
	
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:59,代码来源:MinimapGenerator.java

示例8: getFrame

import com.badlogic.gdx.utils.ScreenUtils; //导入方法依赖的package包/类
public void getFrame() {
   byte[] bytes = ScreenUtils.getFrameBufferPixels(0, 0,Gdx.graphics.getWidth(), Gdx.graphics.getHeight(),false );

}
 
开发者ID:mkostin,项目名称:NASAChallengeDebris,代码行数:5,代码来源:MyGDXSattelite.java


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