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


Java ScreenUtils.getFrameBufferPixmap方法代码示例

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


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

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

示例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,代码行数:21,代码来源:Graphics.java

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

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

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

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

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

示例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:Dakror,项目名称:Vloxlands,代码行数:20,代码来源:Vloxlands.java

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

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

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

示例12: getPNG

import com.badlogic.gdx.utils.ScreenUtils; //导入方法依赖的package包/类
private ByteArrayOutputStream getPNG() throws GetPNGException, IOException {
  Gdx.app.log("Main","getPNG enter");

  ByteArrayOutputStream inMemoryStream = new ByteArrayOutputStream(getWidth() * getHeight() * 4);
  PixmapIO.PNG pngWriter = new PixmapIO.PNG((int)(getWidth() * getHeight() * 1.5f));

  Pixmap pixmap = null;

  try {
    Gdx.app.log("Main","getPNG getFrameBufferPixmap");
    pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, getWidth(), getHeight());

    checkForGlError();

    Gdx.app.log("Main","getPNG writing pixmap to inMemoryStream");
    pngWriter.write(inMemoryStream, pixmap);

    checkForGlError();

  }
  catch (GlErrorException e) {
    throw new GetPNGException(e);
  }
  finally {
    if(pixmap != null) pixmap.dispose();
  }
  Gdx.app.log("Main","getPNG exit");

  return inMemoryStream;
}
 
开发者ID:mc-imperial,项目名称:libgdx-get-image,代码行数:31,代码来源:Main.java

示例13: saveScreenshot

import com.badlogic.gdx.utils.ScreenUtils; //导入方法依赖的package包/类
private static void saveScreenshot() {
     try {
         FileHandle fh;
         do {
             fh = new FileHandle("screenshots/screenshot" + screenShotCounter++ + ".png");
         } while (fh.exists());
         Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0,
                 Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

/* flip the resulting image as opengl draws the
 * opposite way of writing to file */
         ByteBuffer pixels = pixmap.getPixels();
         int numBytes = Gdx.graphics.getWidth() * Gdx.graphics.getHeight() * 4;
         byte[] lines = new byte[numBytes];
         int numBytesPerLine = Gdx.graphics.getWidth() * 4;
         for (int i = 0; i < Gdx.graphics.getHeight(); i++) {
             pixels.position((Gdx.graphics.getHeight() - i - 1) * numBytesPerLine);
             pixels.get(lines, i * numBytesPerLine, numBytesPerLine);
         }
         pixels.clear();
         pixels.put(lines);
         pixels.clear();

         PixmapIO.writePNG(fh, pixmap);
         pixmap.dispose();
     } catch (Exception e) {
         e.printStackTrace();
     }
 }
 
开发者ID:vs-slavchev,项目名称:Virtual-Evil,代码行数:30,代码来源:UiInputProcessor.java

示例14: render

import com.badlogic.gdx.utils.ScreenUtils; //导入方法依赖的package包/类
@Override
public void render () {
	Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
	batch.begin();
	batch.draw(texture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	batch.end();
	
	Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0,  0,  Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
	int color = pixmap.getPixel(0, pixmap.getHeight() - 1);
	Gdx.app.log("AlphaTest", Integer.toHexString(color));
	pixmap.dispose();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:13,代码来源:AlphaTest.java

示例15: takeScreenshot

import com.badlogic.gdx.utils.ScreenUtils; //导入方法依赖的package包/类
public void takeScreenshot(String filename, int w) {

		int h = (int) (w * getSceneCamera().viewportHeight / getSceneCamera().viewportWidth);

		FrameBuffer fbo = new FrameBuffer(Format.RGB565, w, h, false);

		fbo.begin();
		Gdx.gl.glClearColor(0, 0, 0, 1);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		draw();
		Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, w, h);
		fbo.end();

		// 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);

		PixmapIO.writePNG(EngineAssetManager.getInstance().getUserFile(filename), pixmap);

		fbo.dispose();
	}
 
开发者ID:bladecoder,项目名称:bladecoder-adventure-engine,代码行数:30,代码来源:World.java


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