问题描述
我知道如何截取当前帧缓冲区边界的屏幕截图,它只需要屏幕上的视觉绘图像素(游戏场景)。 例如,我画了 15 张图片,如图所示。
BUT 因为您只能看到 6 张图片,因为 FrameBuffer 边界(游戏场景或游戏的相机坐标)
现在:我使用 prefWidth of scrollpane 应用了屏幕截图代码,该代码大于缓冲区宽度以对所有 15 个图像进行截图,如所示代码:
private Stage stage;
private ScrollPane pane;
@Override
public void create() {
stage = new Stage();
Table table = new Table();
for (int i = 0; i < 15; i++)
table.add(new Image(new Texture("badlogic.jpg"))).size(100f).grow();
pane = new ScrollPane(table);
stage.addActor(pane);
Gdx.input.setInputProcessor(stage);
pane.debugall();
}
@Override
public void render() {
Gdx.gl.glClearColor(1,1,1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act();
stage.draw();
if (Gdx.input.isKeyJustpressed(Input.Keys.SPACE)) {
byte[] pixels = ScreenUtils.getFrameBufferPixels(0,(int) pane.getPrefWidth(),Gdx.graphics.getBackBufferHeight(),true);
// This loop makes sure the whole screenshot is opaque and looks exactly like what the user is seeing
for (int i = 4; i < pixels.length; i += 4) {
pixels[i - 1] = (byte) 255;
}
pixmap pixmap = new pixmap((int) pane.getPrefWidth(),pixmap.Format.RGBA8888);
BufferUtils.copy(pixels,pixmap.getPixels(),pixels.length);
pixmapIO.writePNG(Gdx.files.absolute("E:\\Programs\\" + UUID.randomUUID() + ".png"),pixmap);
pixmap.dispose();
}
}
如何在不调整相机大小的情况下将 15 张图像作为整个游戏坐标的屏幕截图(绘制像素 + 不绘制像素)!?
感谢您的帮助!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)