本文整理汇总了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() + "'");
}
示例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() + "'");
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
示例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();
}