本文整理汇总了Java中com.badlogic.gdx.utils.ScreenUtils类的典型用法代码示例。如果您正苦于以下问题:Java ScreenUtils类的具体用法?Java ScreenUtils怎么用?Java ScreenUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScreenUtils类属于com.badlogic.gdx.utils包,在下文中一共展示了ScreenUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: 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
示例17: 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
示例18: 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
示例19: 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
示例20: 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
注:本文中的com.badlogic.gdx.utils.ScreenUtils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论