use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.
the class PngTest method render.
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);
// Write twice to make sure the object is reusable.
writer.write(file, pixmap);
writer.dispose();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
screenshot = new Texture(file);
}
batch.draw(screenshot, 0, 0);
batch.end();
}
use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.
the class TextureFormatTest method create.
@Override
public void create() {
FileHandle file = Gdx.files.internal("data/bobargb8888-32x32.png");
nonMipMapped[0] = new Texture(file, Format.Alpha, false);
nonMipMapped[1] = new Texture(file, Format.LuminanceAlpha, false);
nonMipMapped[2] = new Texture(file, Format.RGB888, false);
nonMipMapped[3] = new Texture(file, Format.RGB565, false);
nonMipMapped[4] = new Texture(file, Format.RGBA8888, false);
nonMipMapped[5] = new Texture(file, Format.RGBA4444, false);
mipMapped[0] = new Texture(file, Format.Alpha, true);
mipMapped[1] = new Texture(file, Format.LuminanceAlpha, true);
mipMapped[2] = new Texture(file, Format.RGB888, true);
mipMapped[3] = new Texture(file, Format.RGB565, true);
mipMapped[4] = new Texture(file, Format.RGBA8888, true);
mipMapped[5] = new Texture(file, Format.RGBA4444, true);
batch = new SpriteBatch();
}
use of com.badlogic.gdx.files.FileHandle in project libgdx by libgdx.
the class ResolutionFileResolver method resolve.
@Override
public FileHandle resolve(String fileName) {
Resolution bestResolution = choose(descriptors);
FileHandle originalHandle = new FileHandle(fileName);
FileHandle handle = baseResolver.resolve(resolve(originalHandle, bestResolution.folder));
if (!handle.exists())
handle = baseResolver.resolve(fileName);
return handle;
}
use of com.badlogic.gdx.files.FileHandle in project Entitas-Java by Rubentxu.
the class TestFileHandleResolver method resolve.
@Override
public FileHandle resolve(String fileName) {
URL url = Thread.currentThread().getContextClassLoader().getResource(fileName);
File file = new File(url.getPath());
return new FileHandle(file);
}
Aggregations