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

public Class ETC1

extends Object
Class Inheritance
Imports
java.io.BufferedInputStream, .DataInputStream, .DataOutputStream, java.nio.Buffer, .ByteBuffer, java.util.zip.GZIPInputStream, .GZIPOutputStream, com.badlogic.gdx.files.FileHandle, com.badlogic.gdx.graphics.Pixmap, .Pixmap.Format, com.badlogic.gdx.math.MathUtils, com.badlogic.gdx.utils.BufferUtils, .Disposable, .GdxRuntimeException, .StreamUtils

Class for encoding and decoding ETC1 compressed images. Also provides methods to add a PKM header.
Author
mzechner

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ETC1.ETC1Data

Class for storing ETC1 compressed image data.

Field Summary

Modifier and TypeField and Description
public static int
public static int
PKM_HEADER_SIZE

The PKM header size in bytes

Constructor Summary

AccessConstructor and Description
public
ETC1()

Method Summary

Modifier and TypeMethod and Description
public static Pixmap

Returns:

the Pixmap
decodeImage
(ETC1.ETC1Data
the ETC1Data instance
etc1Data
,
Pixmap.Format format)

Takes ETC1 compressed image data and converts it to a Format#RGB565 or Format#RGB888 Pixmap.

private static native void
decodeImage(ByteBuffer
the compressed image data in a direct native order ByteBuffer
compressedData
,
int
the offset in bytes to the image data from the start of the buffer
offset
,
ByteBuffer
the decoded data in a direct native order ByteBuffer, must hold width * height * pixelSize bytes.
decodedData
,
int
the offset in bytes to the decoded image data.
offsetDec
,
int
the width in pixels
width
,
int
the height in pixels
height
,
int
the pixel size, either 2 (RBG565) or 3 (RGB888)
pixelSize
)

Decodes the compressed image data to RGB565 or RGB888 pixel data.

public static ETC1.ETC1Data

Returns:

the ETC1Data
encodeImage
(Pixmap
the Pixmap
pixmap
)

Encodes the image via the ETC1 compression scheme.

private static native ByteBuffer

Returns:

a new direct native order ByteBuffer containing the compressed image data
encodeImage
(ByteBuffer
the image data in a direct native order ByteBuffer
imageData
,
int
the offset in bytes to the image data from the start of the buffer
offset
,
int
the width in pixels
width
,
int
the height in pixels
height
,
int
the pixel size, either 2 (RGB565) or 3 (RGB888)
pixelSize
)

Encodes the image data given as RGB565 or RGB888.

public static ETC1.ETC1Data

Returns:

the ETC1Data
encodeImagePKM
(Pixmap
the Pixmap
pixmap
)

Encodes the image via the ETC1 compression scheme.

private static native ByteBuffer

Returns:

a new direct native order ByteBuffer containing the compressed image data
encodeImagePKM
(ByteBuffer
the image data in a direct native order ByteBuffer
imageData
,
int
the offset in bytes to the image data from the start of the buffer
offset
,
int
the width in pixels
width
,
int
the height in pixels
height
,
int
the pixel size, either 2 (RGB565) or 3 (RGB888)
pixelSize
)

Encodes the image data given as RGB565 or RGB888.

public static native void
formatHeader(ByteBuffer
the direct native order ByteBuffer
header
,
int
the offset to the header in bytes
offset
,
int
the width in pixels
width
,
int
the height in pixels
height
)

Writes a PKM header to the ByteBuffer.

public static native int
getCompressedDataSize(int
the width in pixels
width
,
int
the height in pixels
height
)

Returns: the number of bytes needed to store the compressed data

pack-priv static native int
getHeightPKM(ByteBuffer
direct native order ByteBuffer holding the PKM header
header
,
int
the offset in bytes to the PKM header from the ByteBuffer's start
offset
)

Returns: the height stored in the PKM header

private static int
pack-priv static native int
getWidthPKM(ByteBuffer
direct native order ByteBuffer holding the PKM header
header
,
int
the offset in bytes to the PKM header from the ByteBuffer's start
offset
)

Returns: the width stored in the PKM header

pack-priv static native boolean
isValidPKM(ByteBuffer
direct native order ByteBuffer holding the PKM header
header
,
int
the offset in bytes to the PKM header from the ByteBuffer's start
offset
)

Returns: the width stored in the PKM header

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ETC1_RGB8_OESback to summary
public static int ETC1_RGB8_OES
PKM_HEADER_SIZEback to summary
public static int PKM_HEADER_SIZE

The PKM header size in bytes

Constructor Detail

ETC1back to summary
public ETC1()

Method Detail

decodeImageback to summary
public static Pixmap decodeImage(ETC1.ETC1Data etc1Data, Pixmap.Format format)

Takes ETC1 compressed image data and converts it to a Format#RGB565 or Format#RGB888 Pixmap. Does not modify the ByteBuffer's position or limit.

Parameters
etc1Data:ETC1.ETC1Data

the ETC1Data instance

format:Pixmap.Format

either Format#RGB565 or Format#RGB888

Returns:Pixmap

the Pixmap

decodeImageback to summary
private static native void decodeImage(ByteBuffer compressedData, int offset, ByteBuffer decodedData, int offsetDec, int width, int height, int pixelSize)

Decodes the compressed image data to RGB565 or RGB888 pixel data. Does not modify the position or limit of the ByteBuffer instances.

Parameters
compressedData:ByteBuffer

the compressed image data in a direct native order ByteBuffer

offset:int

the offset in bytes to the image data from the start of the buffer

decodedData:ByteBuffer

the decoded data in a direct native order ByteBuffer, must hold width * height * pixelSize bytes.

offsetDec:int

the offset in bytes to the decoded image data.

width:int

the width in pixels

height:int

the height in pixels

pixelSize:int

the pixel size, either 2 (RBG565) or 3 (RGB888)

encodeImageback to summary
public static ETC1.ETC1Data encodeImage(Pixmap pixmap)

Encodes the image via the ETC1 compression scheme. Only Format#RGB565 and Format#RGB888 are supported.

Parameters
pixmap:Pixmap

the Pixmap

Returns:ETC1.ETC1Data

the ETC1Data

encodeImageback to summary
private static native ByteBuffer encodeImage(ByteBuffer imageData, int offset, int width, int height, int pixelSize)

Encodes the image data given as RGB565 or RGB888. Does not modify the position or limit of the ByteBuffer.

Parameters
imageData:ByteBuffer

the image data in a direct native order ByteBuffer

offset:int

the offset in bytes to the image data from the start of the buffer

width:int

the width in pixels

height:int

the height in pixels

pixelSize:int

the pixel size, either 2 (RGB565) or 3 (RGB888)

Returns:ByteBuffer

a new direct native order ByteBuffer containing the compressed image data

encodeImagePKMback to summary
public static ETC1.ETC1Data encodeImagePKM(Pixmap pixmap)

Encodes the image via the ETC1 compression scheme. Only Format#RGB565 and Format#RGB888 are supported. Adds a PKM header in front of the compressed image data.

Parameters
pixmap:Pixmap

the Pixmap

Returns:ETC1.ETC1Data

the ETC1Data

encodeImagePKMback to summary
private static native ByteBuffer encodeImagePKM(ByteBuffer imageData, int offset, int width, int height, int pixelSize)

Encodes the image data given as RGB565 or RGB888. Does not modify the position or limit of the ByteBuffer.

Parameters
imageData:ByteBuffer

the image data in a direct native order ByteBuffer

offset:int

the offset in bytes to the image data from the start of the buffer

width:int

the width in pixels

height:int

the height in pixels

pixelSize:int

the pixel size, either 2 (RGB565) or 3 (RGB888)

Returns:ByteBuffer

a new direct native order ByteBuffer containing the compressed image data

formatHeaderback to summary
public static native void formatHeader(ByteBuffer header, int offset, int width, int height)

Writes a PKM header to the ByteBuffer. Does not modify the position or limit of the ByteBuffer.

Parameters
header:ByteBuffer

the direct native order ByteBuffer

offset:int

the offset to the header in bytes

width:int

the width in pixels

height:int

the height in pixels

getCompressedDataSizeback to summary
public static native int getCompressedDataSize(int width, int height)
Parameters
width:int

the width in pixels

height:int

the height in pixels

Returns:int

the number of bytes needed to store the compressed data

getHeightPKMback to summary
pack-priv static native int getHeightPKM(ByteBuffer header, int offset)
Parameters
header:ByteBuffer

direct native order ByteBuffer holding the PKM header

offset:int

the offset in bytes to the PKM header from the ByteBuffer's start

Returns:int

the height stored in the PKM header

getPixelSizeback to summary
private static int getPixelSize(Pixmap.Format format)
getWidthPKMback to summary
pack-priv static native int getWidthPKM(ByteBuffer header, int offset)
Parameters
header:ByteBuffer

direct native order ByteBuffer holding the PKM header

offset:int

the offset in bytes to the PKM header from the ByteBuffer's start

Returns:int

the width stored in the PKM header

isValidPKMback to summary
pack-priv static native boolean isValidPKM(ByteBuffer header, int offset)
Parameters
header:ByteBuffer

direct native order ByteBuffer holding the PKM header

offset:int

the offset in bytes to the PKM header from the ByteBuffer's start

Returns:boolean

the width stored in the PKM header

com.badlogic.gdx.graphics.glutils back to summary

public final Class ETC1.ETC1Data

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

Class for storing ETC1 compressed image data.
Author
mzechner

Field Summary

Modifier and TypeField and Description
public final ByteBuffer
compressedData

the optional PKM header and compressed image data

public final int
dataOffset

the offset in bytes to the actual compressed data.

public final int
height

the height in pixels

public final int
width

the width in pixels

Constructor Summary

AccessConstructor and Description
public
ETC1Data(int width, int height, ByteBuffer compressedData, int dataOffset)

public

Method Summary

Modifier and TypeMethod and Description
private void
public void
dispose()

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

Releases the native resources of the ETC1Data instance.

public boolean
hasPKMHeader()

Returns: whether this ETC1Data has a PKM header

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
write(FileHandle
the file.
file
)

Writes the ETC1Data with a PKM header to the given file.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

compressedDataback to summary
public final ByteBuffer compressedData

the optional PKM header and compressed image data

dataOffsetback to summary
public final int dataOffset

the offset in bytes to the actual compressed data. Might be 16 if this contains a PKM header, 0 otherwise

heightback to summary
public final int height

the height in pixels

widthback to summary
public final int width

the width in pixels

Constructor Detail

ETC1Databack to summary
public ETC1Data(int width, int height, ByteBuffer compressedData, int dataOffset)
ETC1Databack to summary
public ETC1Data(FileHandle pkmFile)

Method Detail

checkNPOTback to summary
private void checkNPOT()
disposeback to summary
public void dispose()

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

Releases the native resources of the ETC1Data instance.

hasPKMHeaderback to summary
public boolean hasPKMHeader()
Returns:boolean

whether this ETC1Data has a PKM header

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

writeback to summary
public void write(FileHandle file)

Writes the ETC1Data with a PKM header to the given file.

Parameters
file:FileHandle

the file.