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();
}
java类com.badlogic.gdx.graphics.PixmapIO的实例源码
ScreenshotUtils.java 文件源码
项目:ProjektGG
阅读 32
收藏 0
点赞 0
评论 0
BitmapFontWriter.java 文件源码
项目:Cubes_2
阅读 31
收藏 0
点赞 0
评论 0
/** A utility method to write the given array of pixmaps to the given output directory, with the specified file name. If the
* pages array is of length 1, then the resulting file ref will look like: "fileName.png".
*
* If the pages array is greater than length 1, the resulting file refs will be appended with "_N", such as "fileName_0.png",
* "fileName_1.png", "fileName_2.png" etc.
*
* The returned string array can then be passed to the <tt>writeFont</tt> method.
*
* Note: None of the pixmaps will be disposed.
*
* @param pages the pages of pixmap data to write
* @param outputDir the output directory
* @param fileName the file names for the output images
* @return the array of string references to be used with <tt>writeFont</tt> */
public static String[] writePixmaps (Pixmap[] pages, FileHandle outputDir, String fileName) {
if (pages == null || pages.length == 0) throw new IllegalArgumentException("no pixmaps supplied to BitmapFontWriter.write");
String[] pageRefs = new String[pages.length];
for (int i = 0; i < pages.length; i++) {
String ref = pages.length == 1 ? (fileName + ".png") : (fileName + "_" + i + ".png");
// the ref for this image
pageRefs[i] = ref;
// write the PNG in that directory
PixmapIO.writePNG(outputDir.child(ref), pages[i]);
}
return pageRefs;
}
BitmapFontWriter.java 文件源码
项目:enklave
阅读 20
收藏 0
点赞 0
评论 0
/** A utility method to write the given array of pixmaps to the given output directory, with the specified file name. If the
* pages array is of length 1, then the resulting file ref will look like: "fileName.png".
*
* If the pages array is greater than length 1, the resulting file refs will be appended with "_N", such as "fileName_0.png",
* "fileName_1.png", "fileName_2.png" etc.
*
* The returned string array can then be passed to the <tt>writeFont</tt> method.
*
* Note: None of the pixmaps will be disposed.
*
* @param pages the pages of pixmap data to write
* @param outputDir the output directory
* @param fileName the file names for the output images
* @return the array of string references to be used with <tt>writeFont</tt> */
public static String[] writePixmaps (Pixmap[] pages, FileHandle outputDir, String fileName) {
if (pages==null || pages.length==0)
throw new IllegalArgumentException("no pixmaps supplied to BitmapFontWriter.write");
String[] pageRefs = new String[pages.length];
for (int i=0; i<pages.length; i++) {
String ref = pages.length==1 ? (fileName+".png") : (fileName+"_"+i+".png");
//the ref for this image
pageRefs[i] = ref;
//write the PNG in that directory
PixmapIO.writePNG(outputDir.child(ref), pages[i]);
}
return pageRefs;
}
BitmapFontWriter.java 文件源码
项目:Cubes
阅读 26
收藏 0
点赞 0
评论 0
/** A utility method to write the given array of pixmaps to the given output directory, with the specified file name. If the
* pages array is of length 1, then the resulting file ref will look like: "fileName.png".
*
* If the pages array is greater than length 1, the resulting file refs will be appended with "_N", such as "fileName_0.png",
* "fileName_1.png", "fileName_2.png" etc.
*
* The returned string array can then be passed to the <tt>writeFont</tt> method.
*
* Note: None of the pixmaps will be disposed.
*
* @param pages the pages of pixmap data to write
* @param outputDir the output directory
* @param fileName the file names for the output images
* @return the array of string references to be used with <tt>writeFont</tt> */
public static String[] writePixmaps (Pixmap[] pages, FileHandle outputDir, String fileName) {
if (pages == null || pages.length == 0) throw new IllegalArgumentException("no pixmaps supplied to BitmapFontWriter.write");
String[] pageRefs = new String[pages.length];
for (int i = 0; i < pages.length; i++) {
String ref = pages.length == 1 ? (fileName + ".png") : (fileName + "_" + i + ".png");
// the ref for this image
pageRefs[i] = ref;
// write the PNG in that directory
PixmapIO.writePNG(outputDir.child(ref), pages[i]);
}
return pageRefs;
}
BitmapFontWriter.java 文件源码
项目:JavityEngine
阅读 51
收藏 0
点赞 0
评论 0
/** A utility method to write the given array of pixmaps to the given output directory, with the specified file name. If the
* pages array is of length 1, then the resulting file ref will look like: "fileName.png".
*
* If the pages array is greater than length 1, the resulting file refs will be appended with "_N", such as "fileName_0.png",
* "fileName_1.png", "fileName_2.png" etc.
*
* The returned string array can then be passed to the <tt>writeFont</tt> method.
*
* Note: None of the pixmaps will be disposed.
*
* @param pages the pages of pixmap data to write
* @param outputDir the output directory
* @param fileName the file names for the output images
* @return the array of string references to be used with <tt>writeFont</tt> */
public static String[] writePixmaps (Pixmap[] pages, FileHandle outputDir, String fileName) {
if (pages==null || pages.length==0)
throw new IllegalArgumentException("no pixmaps supplied to BitmapFontWriter.write");
String[] pageRefs = new String[pages.length];
for (int i=0; i<pages.length; i++) {
String ref = pages.length==1 ? (fileName+".png") : (fileName+"_"+i+".png");
//the ref for this image
pageRefs[i] = ref;
//write the PNG in that directory
PixmapIO.writePNG(outputDir.child(ref), pages[i]);
}
return pageRefs;
}
ScreenshotFactory.java 文件源码
项目:Argent
阅读 28
收藏 0
点赞 0
评论 0
public static void saveScreenshot(final int w, final int h, final String prefix)
{
try
{
FileHandle fh;
do
{
if (Gdx.app.getType() == ApplicationType.Desktop)
{
fh = Gdx.files.local("bin/screenshot_" + prefix + "_" + counter++ + ".png");
}
else
{
fh = Gdx.files.local("screenshot_" + prefix + "_" + counter++ + ".png");
}
}
while (fh.exists());
final Pixmap pixmap = getScreenshot(0, 0, w, h, true);
PixmapIO.writePNG(fh, pixmap);
pixmap.dispose();
Gdx.app.log("screenshot", "Screenshot saved to " + fh);
}
catch (final Exception e)
{
}
}
FilteredTextureData.java 文件源码
项目:inari-firefly-libGDX
阅读 27
收藏 0
点赞 0
评论 0
@Override
public void prepare () {
if (isPrepared) throw new GdxRuntimeException("Already prepared");
if (pixmap == null) {
if (file.extension().equals("cim"))
pixmap = PixmapIO.readCIM(file);
else
pixmap = ensurePot(new Pixmap(file));
width = pixmap.getWidth();
height = pixmap.getHeight();
if (format == null) format = pixmap.getFormat();
}
applyFilter( pixmap );
isPrepared = true;
}
ScreenshotHelper.java 文件源码
项目:ns2-scc-profiler
阅读 45
收藏 0
点赞 0
评论 0
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) {
}
}
}
ScreenshotHelper.java 文件源码
项目:ns2-scc-profiler
阅读 32
收藏 0
点赞 0
评论 0
public void saveMapTexture(GameState state, Layer layer) {
Pixmap pixmap = layer.pixmap;
try {
PixmapIO.PNG writer = new PixmapIO.PNG((int) (pixmap.getWidth() * pixmap.getHeight() * 1.5f)); // Guess at deflated size.
try {
writer.setFlipY(false);
ByteArrayOutputStream pngStream = new ByteArrayOutputStream();
writer.write(pngStream, pixmap);
state.layer = pngStream.toByteArray();
} finally {
writer.dispose();
}
} catch (IOException ex) {
throw new RuntimeException("Could not save map as texture.");
}
}
BitmapFontWriter.java 文件源码
项目:libgdxcn
阅读 25
收藏 0
点赞 0
评论 0
/** A utility method to write the given array of pixmaps to the given output directory, with the specified file name. If the
* pages array is of length 1, then the resulting file ref will look like: "fileName.png".
*
* If the pages array is greater than length 1, the resulting file refs will be appended with "_N", such as "fileName_0.png",
* "fileName_1.png", "fileName_2.png" etc.
*
* The returned string array can then be passed to the <tt>writeFont</tt> method.
*
* Note: None of the pixmaps will be disposed.
*
* @param pages the pages of pixmap data to write
* @param outputDir the output directory
* @param fileName the file names for the output images
* @return the array of string references to be used with <tt>writeFont</tt> */
public static String[] writePixmaps (Pixmap[] pages, FileHandle outputDir, String fileName) {
if (pages == null || pages.length == 0)
throw new IllegalArgumentException("no pixmaps supplied to BitmapFontWriter.write");
String[] pageRefs = new String[pages.length];
for (int i = 0; i < pages.length; i++) {
String ref = pages.length == 1 ? (fileName + ".png") : (fileName + "_" + i + ".png");
// the ref for this image
pageRefs[i] = ref;
// write the PNG in that directory
PixmapIO.writePNG(outputDir.child(ref), pages[i]);
}
return pageRefs;
}
BitmapFontWriter.java 文件源码
项目:gdx-smart-font
阅读 23
收藏 0
点赞 0
评论 0
/** A utility method to write the given array of pixmaps to the given output directory, with the specified file name. If the
* pages array is of length 1, then the resulting file ref will look like: "fileName.png".
*
* If the pages array is greater than length 1, the resulting file refs will be appended with "_N", such as "fileName_0.png",
* "fileName_1.png", "fileName_2.png" etc.
*
* The returned string array can then be passed to the <tt>writeFont</tt> method.
*
* Note: None of the pixmaps will be disposed.
*
* @param pages the pages of pixmap data to write
* @param outputDir the output directory
* @param fileName the file names for the output images
* @return the array of string references to be used with <tt>writeFont</tt> */
public static String[] writePixmaps (Pixmap[] pages, FileHandle outputDir, String fileName) {
if (pages==null || pages.length==0)
throw new IllegalArgumentException("no pixmaps supplied to BitmapFontWriter.write");
String[] pageRefs = new String[pages.length];
for (int i=0; i<pages.length; i++) {
String ref = pages.length==1 ? (fileName+".png") : (fileName+"_"+i+".png");
//the ref for this image
pageRefs[i] = ref;
//write the PNG in that directory
PixmapIO.writePNG(outputDir.child(ref), pages[i]);
}
return pageRefs;
}
MarketUtils.java 文件源码
项目:gametemplate
阅读 26
收藏 0
点赞 0
评论 0
private static void saveScreenshot() throws IOException {
int w = Gdx.graphics.getWidth();
int h = Gdx.graphics.getHeight();
final Pixmap pixmap = new Pixmap(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), Format.RGBA8888);
ByteBuffer pixels = pixmap.getPixels();
Gdx.gl.glReadPixels(0, 0, w, h, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixels);
final int numBytes = w * h * 4;
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);
System.out.println("Captured.");
PixmapIO.writePNG(new FileHandle(androidDir+(++photoNumber)+".png"), pixmap);
}
ImageRenderer.java 文件源码
项目:gaiasky
阅读 21
收藏 0
点赞 0
评论 0
public static String writePixmapToImage(String absoluteLocation, String baseFileName, Pixmap pixmap, ImageType type) {
/** Make sure the directory exists **/
FileHandle dir = Gdx.files.absolute(absoluteLocation);
dir.mkdirs();
/** Save to file **/
FileHandle fh = getTarget(absoluteLocation, baseFileName, type);
switch (type) {
case PNG:
PixmapIO.writePNG(fh, pixmap);
break;
case JPG:
JPGWriter.write(fh, pixmap);
break;
}
return fh.path();
}
ScreenshotFactory.java 文件源码
项目:snappyfrog
阅读 35
收藏 0
点赞 0
评论 0
public static String saveScreenshot(String destinationFolder, boolean yDown){
FileHandle fh;
try{
do{
fh = new FileHandle(destinationFolder + "snappyfrog-" + counter++ + ".png");
}while (fh.exists());
Pixmap pixmap = getScreenshot(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), yDown);
PixmapIO.writePNG(fh, pixmap);
pixmap.dispose();
}catch (Exception e){
System.out.println("Error happened while saving screenshot: " + e.getMessage());
return "";
}
return fh.path();
}
ScreenshotHelper.java 文件源码
项目:ns2-scc-profiler
阅读 31
收藏 0
点赞 0
评论 0
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) {
}
}
}
ScreenshotHelper.java 文件源码
项目:ns2-scc-profiler
阅读 29
收藏 0
点赞 0
评论 0
public void saveMapTexture(GameState state, Layer layer) {
Pixmap pixmap = layer.pixmap;
try {
PixmapIO.PNG writer = new PixmapIO.PNG((int) (pixmap.getWidth() * pixmap.getHeight() * 1.5f)); // Guess at deflated size.
try {
writer.setFlipY(false);
ByteArrayOutputStream pngStream = new ByteArrayOutputStream();
writer.write(pngStream, pixmap);
state.layer = pngStream.toByteArray();
} finally {
writer.dispose();
}
} catch (IOException ex) {
throw new RuntimeException("Could not save map as texture.");
}
}
BitmapFontWriter.java 文件源码
项目:gdx-proto
阅读 28
收藏 0
点赞 0
评论 0
/** A utility method to write the given array of pixmaps to the given output directory, with the specified file name. If the
* pages array is of length 1, then the resulting file ref will look like: "fileName.png".
*
* If the pages array is greater than length 1, the resulting file refs will be appended with "_N", such as "fileName_0.png",
* "fileName_1.png", "fileName_2.png" etc.
*
* The returned string array can then be passed to the <tt>writeFont</tt> method.
*
* Note: None of the pixmaps will be disposed.
*
* @param pages the pages of pixmap data to write
* @param outputDir the output directory
* @param fileName the file names for the output images
* @return the array of string references to be used with <tt>writeFont</tt> */
public static String[] writePixmaps (Pixmap[] pages, FileHandle outputDir, String fileName) {
if (pages==null || pages.length==0)
throw new IllegalArgumentException("no pixmaps supplied to BitmapFontWriter.write");
String[] pageRefs = new String[pages.length];
for (int i=0; i<pages.length; i++) {
String ref = pages.length==1 ? (fileName+".png") : (fileName+"_"+i+".png");
//the ref for this image
pageRefs[i] = ref;
//write the PNG in that directory
PixmapIO.writePNG(outputDir.child(ref), pages[i]);
}
return pageRefs;
}
Utils.java 文件源码
项目:crabox
阅读 27
收藏 0
点赞 0
评论 0
public static void saveScreen() {
int count = 0;
try {
FileHandle f;
do {
f = new FileHandle("screenshoot"+ count++ +".png");
}while(f.exists());
Pixmap px = takeScreenShoot();
PixmapIO.writePNG(f, px);
px.dispose();
}catch(Exception e) {
e.printStackTrace();
}
}
TemplateMain.java 文件源码
项目:libgdx-lwp-template
阅读 27
收藏 0
点赞 0
评论 0
private void makeScreenshot(){
int w = Gdx.graphics.getWidth();
int h = Gdx.graphics.getHeight();
Gdx.gl.glPixelStorei(GL10.GL_PACK_ALIGNMENT, 1);
final Pixmap pixmap = new Pixmap(w, h, Format.RGBA8888);
ByteBuffer pixels = pixmap.getPixels();
Gdx.gl.glReadPixels(0, 0, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, pixels);
final int numBytes = w * h * 4;
byte[] lines = new byte[numBytes];
pixels.clear();
pixels.get(lines);
String stamp = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(Calendar.getInstance().getTime());
PixmapIO.writePNG(Gdx.files.local("Screenshot-" + stamp + ".png"), pixmap);
pixmap.dispose();
}
AsyncImageTest.java 文件源码
项目:ead
阅读 20
收藏 0
点赞 0
评论 0
private void createImage() {
Pixmap pixmap = new Pixmap(200, 200, Format.RGBA8888);
pixmap.setColor((float) Math.random(), (float) Math.random(),
(float) Math.random(), 1.0f);
pixmap.fill();
PixmapIO.writePNG(
controller.getApplicationAssets().absolute(
file.getAbsolutePath()), pixmap);
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
controller.getEditorGameAssets().unload(file.toString());
controller.getEditorGameAssets().load(file.toString(),
Texture.class);
}
});
}
ScreenshotUtil.java 文件源码
项目:shadow-engine
阅读 36
收藏 0
点赞 0
评论 0
public static void frameSave(final FileHandle fh) {
final int w = (int) Shadow.dispw;
final int h = (int) Shadow.disph;
final byte[] data = getScreenData(0, 0, w, h);
Thread thread = new Thread("Screenshot_"+Shadow.rand.nextInt(1024)) {
@Override
public void run() {
Pixmap pixmap = getPixmap(w, h);
fillPixmap(pixmap, data);
fh.parent().mkdirs();
PixmapIO.writePNG(fh, pixmap);
}
};
thread.start();
}
Screenshot.java 文件源码
项目:gdx-toolbox
阅读 28
收藏 0
点赞 0
评论 0
public static void take(String createInPath) {
String prefix;
if (Strings.isNullOrEmpty(createInPath))
prefix = "screenshot";
else if (createInPath.endsWith("/"))
prefix = createInPath + "screenshot";
else
prefix = createInPath + "/screenshot";
try {
FileHandle file;
do {
file = new FileHandle(prefix + counter + ".png");
counter++;
} while (file.exists());
Pixmap pixmap = getFrameBufferPixmap(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
PixmapIO.writePNG(file, pixmap);
pixmap.dispose();
Gdx.app.log("Screenshot", String.format("Saved screenshot to %s", file.file().getAbsolutePath()));
} catch (Exception e) {
}
}
FileTextureData.java 文件源码
项目:ingress-indonesia-dev
阅读 31
收藏 0
点赞 0
评论 0
public void prepare()
{
if (this.isPrepared)
throw new GdxRuntimeException("Already prepared");
if (this.pixmap == null)
if (!this.file.extension().equals("cim"))
break label96;
label96: for (this.pixmap = PixmapIO.readCIM(this.file); ; this.pixmap = ensurePot(new Pixmap(this.file)))
{
this.width = this.pixmap.getWidth();
this.height = this.pixmap.getHeight();
if (this.format == null)
this.format = this.pixmap.getFormat();
this.isPrepared = true;
return;
}
}
AOTextureGenerator.java 文件源码
项目:Cubes_2
阅读 22
收藏 0
点赞 0
评论 0
protected static void generate(FileHandle file, float strength) {
Pixmap blocks = new Pixmap(INDIVIDUAL_SIZE * 3, INDIVIDUAL_SIZE * 3, AOTextureGenerator.FORMAT);
Pixmap gaussian = new Pixmap(INDIVIDUAL_SIZE, INDIVIDUAL_SIZE, AOTextureGenerator.FORMAT);
Pixmap output = new Pixmap(TEXTURE_SIZE, TEXTURE_SIZE, AOTextureGenerator.FORMAT);
double[][] gwm = AOTextureGenerator.gaussianWeightMatrix(SIGMA);
int gaussianRadius = (gwm.length - 1) / 2;
Color blockColor = new Color(strength, strength, strength, 1f);
for (int i = 0; i < TOTAL; i++) {
String n = name(i);
System.out.print(n + " ");
AOTextureGenerator.clearPixmap(blocks);
AOTextureGenerator.clearPixmap(gaussian);
AOTextureGenerator.setupPixmap(blocks, i, blockColor);
AOTextureGenerator.gaussianPixmap(blocks, gaussian, gwm, gaussianRadius);
// PixmapIO.writePNG(folder.child(n + "_blocks_" + sigma + ".png"),
// blocks);
// PixmapIO.writePNG(folder.child(n + "_gaussian_" + sigma +
// ".png"), gaussian);
output.drawPixmap(gaussian, (i % SQRT_TOTAL) * INDIVIDUAL_SIZE, (i / SQRT_TOTAL) * INDIVIDUAL_SIZE, 0, 0,
INDIVIDUAL_SIZE, INDIVIDUAL_SIZE);
if (i % SQRT_TOTAL == SQRT_TOTAL - 1)
System.out.println();
}
PixmapIO.writePNG(file, output);
output.dispose();
blocks.dispose();
gaussian.dispose();
}
Assets.java 文件源码
项目:Cubes_2
阅读 34
收藏 0
点赞 0
评论 0
private static PackedTextureSheet getPackedTextureSheet(AssetType... assetType) {
if (Adapter.isDedicatedServer())
return null;
TexturePacker texturePacker = new TexturePacker(2048, 2048, 1, true);
Pixmap pixmap;
getPacketTextureSheetFor(assetType, texturePacker, pixmap);
FileHandle fileHandle = assetsFolder.child("packed");
fileHandle.mkdirs();
Compatibility.get().nomedia(fileHandle);
fileHandle = fileHandle.child(assetType[0].name() + ".cim");
try {
PixmapIO.writeCIM(fileHandle, texturePacker.getPixmap());
} catch (GdxRuntimeException e) {
Log.error("Failed to write packed image", e);
}
Texture texture = new Texture(fileHandle);
texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
PackedTextureSheet packedTextureSheet = new PackedTextureSheet(
new Material(TextureAttribute.createDiffuse(texture)));
packedTextureSheet.getMaterial().set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
Map<Asset, TexturePacker.PackRectangle> rectangles = texturePacker.getRectangles();
int num = 0;
for (Map.Entry<Asset, TexturePacker.PackRectangle> entry : rectangles.entrySet()) {
num++;
TextureRegion textureRegion = new TextureRegion(texture, entry.getValue().x, entry.getValue().y,
entry.getValue().width, entry.getValue().height);
entry.getKey().setPackedTextureRegion(textureRegion, packedTextureSheet);
packedTextureSheet.getPackedTextures().put(entry.getKey().toString(), textureRegion);
}
for (AssetType type : assetType) {
type.setPackedTextureSheet(packedTextureSheet);
}
return packedTextureSheet;
}
AOTextureGenerator.java 文件源码
项目:Cubes
阅读 27
收藏 0
点赞 0
评论 0
protected static void generate(FileHandle file, float strength) {
Pixmap blocks = new Pixmap(INDIVIDUAL_SIZE * 3, INDIVIDUAL_SIZE * 3, AOTextureGenerator.FORMAT);
Pixmap gaussian = new Pixmap(INDIVIDUAL_SIZE, INDIVIDUAL_SIZE, AOTextureGenerator.FORMAT);
Pixmap output = new Pixmap(TEXTURE_SIZE, TEXTURE_SIZE, AOTextureGenerator.FORMAT);
double[][] gwm = AOTextureGenerator.gaussianWeightMatrix(SIGMA);
int gaussianRadius = (gwm.length - 1) / 2;
Color blockColor = new Color(strength, strength, strength, 1f);
for (int i = 0; i < TOTAL; i++) {
String n = name(i);
System.out.print(n + " ");
AOTextureGenerator.clearPixmap(blocks);
AOTextureGenerator.clearPixmap(gaussian);
AOTextureGenerator.setupPixmap(blocks, i, blockColor);
AOTextureGenerator.gaussianPixmap(blocks, gaussian, gwm, gaussianRadius);
//PixmapIO.writePNG(folder.child(n + "_blocks_" + sigma + ".png"), blocks);
//PixmapIO.writePNG(folder.child(n + "_gaussian_" + sigma + ".png"), gaussian);
output.drawPixmap(gaussian, (i % SQRT_TOTAL) * INDIVIDUAL_SIZE, (i / SQRT_TOTAL) * INDIVIDUAL_SIZE, 0, 0, INDIVIDUAL_SIZE, INDIVIDUAL_SIZE);
if (i % SQRT_TOTAL == SQRT_TOTAL - 1) System.out.println();
}
PixmapIO.writePNG(file, output);
output.dispose();
blocks.dispose();
gaussian.dispose();
}
MainGameClass.java 文件源码
项目:GangsterSquirrel
阅读 20
收藏 0
点赞 0
评论 0
/**
* 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();
}
ScreenShotUtil.java 文件源码
项目:jrpg-engine
阅读 30
收藏 0
点赞 0
评论 0
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();
}
ScreenshotFactory.java 文件源码
项目:gdxjam-ugg
阅读 26
收藏 0
点赞 0
评论 0
public static void saveScreenshot () {
String path = directory + "screenshot" + counter++ + ".png";
while(Gdx.files.local(path).exists()){
counter++;
path = directory + "screenshot" + counter++ + ".png";
}
Pixmap pixmap = getScreenshot(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
PixmapIO.writePNG(Gdx.files.local(path), pixmap);
pixmap.dispose();
}
Main.java 文件源码
项目:libgdx-get-image
阅读 28
收藏 0
点赞 0
评论 0
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;
}