APIdia Launch Partner
Top Description Inners Constructors Methods
com.badlogic.gdx.graphics

public Class PixmapIO

extends Object
Class Inheritance
Imports
java.io.BufferedInputStream, .ByteArrayOutputStream, .DataInputStream, .DataOutputStream, .IOException, .OutputStream, java.nio.Buffer, .ByteBuffer, java.util.zip.CRC32, .CheckedOutputStream, .Deflater, .DeflaterOutputStream, .InflaterInputStream, com.badlogic.gdx.files.FileHandle, com.badlogic.gdx.graphics.Pixmap.Format, com.badlogic.gdx.utils.ByteArray, .Disposable, .GdxRuntimeException, .StreamUtils

Writes Pixmaps to various formats.
Authors
mzechner, Nathan Sweet

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static class
PixmapIO.PNG

PNG encoder with compression.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static Pixmap
readCIM(FileHandle
the file to read the Pixmap from
file
)

Reads the Pixmap from the given file, assuming the Pixmap was written with the PixmapIO#writeCIM(FileHandle, Pixmap) method.

public static void
writeCIM(FileHandle
the file to write the Pixmap to
file
,
Pixmap pixmap)

Writes the Pixmap to the given file using a custom compression scheme.

public static void
writePNG(FileHandle file, Pixmap pixmap, int
sets the deflate compression level. Default is Deflater#DEFAULT_COMPRESSION
compression
,
boolean
flips the Pixmap vertically if true
flipY
)

Writes the pixmap as a PNG.

public static void
writePNG(FileHandle file, Pixmap pixmap)

Writes the pixmap as a PNG with compression.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

PixmapIOback to summary
public PixmapIO()

Method Detail

readCIMback to summary
public static Pixmap readCIM(FileHandle file)

Reads the Pixmap from the given file, assuming the Pixmap was written with the PixmapIO#writeCIM(FileHandle, Pixmap) method. Throws a GdxRuntimeException in case the file couldn't be read.

Parameters
file:FileHandle

the file to read the Pixmap from

writeCIMback to summary
public static void writeCIM(FileHandle file, Pixmap pixmap)

Writes the Pixmap to the given file using a custom compression scheme. First three integers define the width, height and format, remaining bytes are zlib compressed pixels. To be able to load the Pixmap to a Texture, use ".cim" as the file suffix. Throws a GdxRuntimeException in case the Pixmap couldn't be written to the file.

Parameters
file:FileHandle

the file to write the Pixmap to

writePNGback to summary
public static void writePNG(FileHandle file, Pixmap pixmap, int compression, boolean flipY)

Writes the pixmap as a PNG. See PNG to write out multiple PNGs with minimal allocation.

Parameters
compression:int

sets the deflate compression level. Default is Deflater#DEFAULT_COMPRESSION

flipY:boolean

flips the Pixmap vertically if true

writePNGback to summary
public static void writePNG(FileHandle file, Pixmap pixmap)

Writes the pixmap as a PNG with compression. See PNG to configure the compression level, more efficiently flip the pixmap vertically, and to write out multiple PNGs with minimal allocation.

com.badlogic.gdx.graphics back to summary

private Class PixmapIO.CIM

extends Object
Class Inheritance

Author
mzechner

Field Summary

Modifier and TypeField and Description
private static final int
private static final byte[]
private static final byte[]

Constructor Summary

AccessConstructor and Description
private
CIM()

Method Summary

Modifier and TypeMethod and Description
public static Pixmap
public static void
write(FileHandle file, Pixmap pixmap)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BUFFER_SIZEback to summary
private static final int BUFFER_SIZE
readBufferback to summary
private static final byte[] readBuffer
writeBufferback to summary
private static final byte[] writeBuffer

Constructor Detail

CIMback to summary
private CIM()

Method Detail

readback to summary
public static Pixmap read(FileHandle file)
writeback to summary
public static void write(FileHandle file, Pixmap pixmap)
com.badlogic.gdx.graphics back to summary

public Class PixmapIO.PNG

extends Object
implements Disposable
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.utils.Disposable

PNG encoder with compression. An instance can be reused to encode multiple PNGs with minimal allocation.
Copyright (c) 2007 Matthias Mann - www.matthiasmann.de
Copyright (c) 2014 Nathan Sweet

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Authors
Matthias Mann, Nathan Sweet

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final PixmapIO.PNG.ChunkBuffer
private static final byte
private static final byte
private ByteArray
private final Deflater
private static final byte
private boolean
private static final int
private static final int
private static final int
private static final byte
private int
private ByteArray
private static final byte
private ByteArray
private static final byte[]

Constructor Summary

AccessConstructor and Description
public
PNG()

public
PNG(int initialBufferSize)

Method Summary

Modifier and TypeMethod and Description
public void
dispose()

Implements com.badlogic.gdx.utils.Disposable.dispose.

Disposal will happen automatically in finalize() but can be done explicitly if desired.

public void
setCompression(int level)

Sets the deflate compression level.

public void
setFlipY(boolean flipY)

If true, the resulting PNG is flipped vertically.

public void
write(FileHandle file, Pixmap pixmap)

public void
write(OutputStream output, Pixmap pixmap)

Writes the pixmap to the stream without closing the stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
private final PixmapIO.PNG.ChunkBuffer buffer
COLOR_ARGBback to summary
private static final byte COLOR_ARGB
COMPRESSION_DEFLATEback to summary
private static final byte COMPRESSION_DEFLATE
curLineBytesback to summary
private ByteArray curLineBytes
deflaterback to summary
private final Deflater deflater
FILTER_NONEback to summary
private static final byte FILTER_NONE
flipYback to summary
private boolean flipY
IDATback to summary
private static final int IDAT
IENDback to summary
private static final int IEND
IHDRback to summary
private static final int IHDR
INTERLACE_NONEback to summary
private static final byte INTERLACE_NONE
lastLineLenback to summary
private int lastLineLen
lineOutBytesback to summary
private ByteArray lineOutBytes
PAETHback to summary
private static final byte PAETH
prevLineBytesback to summary
private ByteArray prevLineBytes
SIGNATUREback to summary
private static final byte[] SIGNATURE

Constructor Detail

PNGback to summary
public PNG()
PNGback to summary
public PNG(int initialBufferSize)

Method Detail

disposeback to summary
public void dispose()

Implements com.badlogic.gdx.utils.Disposable.dispose.

Disposal will happen automatically in finalize() but can be done explicitly if desired.

Annotations
@SuppressWarnings:javadoc
setCompressionback to summary
public void setCompression(int level)

Sets the deflate compression level. Default is Deflater#DEFAULT_COMPRESSION.

setFlipYback to summary
public void setFlipY(boolean flipY)

If true, the resulting PNG is flipped vertically. Default is true.

writeback to summary
public void write(FileHandle file, Pixmap pixmap) throws IOException
writeback to summary
public void write(OutputStream output, Pixmap pixmap) throws IOException

Writes the pixmap to the stream without closing the stream.

com.badlogic.gdx.graphics back to summary

pack-priv Class PixmapIO.PNG.ChunkBuffer

extends DataOutputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final ByteArrayOutputStream
pack-priv final CRC32
Inherited from java.io.DataOutputStream:
written

Constructor Summary

AccessConstructor and Description
pack-priv
ChunkBuffer(int initialSize)

private

Field Detail

bufferback to summary
pack-priv final ByteArrayOutputStream buffer
crcback to summary
pack-priv final CRC32 crc

Constructor Detail

ChunkBufferback to summary
pack-priv ChunkBuffer(int initialSize)
ChunkBufferback to summary
private ChunkBuffer(ByteArrayOutputStream buffer, CRC32 crc)

Method Detail

endChunkback to summary
public void endChunk(DataOutputStream target) throws IOException