Most visited

Recently visited

Added in API level 8

ETC1

public class ETC1
extends Object

java.lang.Object
   ↳ android.opengl.ETC1


编码和解码ETC1纹理的方法。

ETC1纹理格式的标准可以在http://www.khronos.org/registry/gles/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt找到。

PKM文件格式是一个16字节的头文件,它描述了编码后的ETC1纹理数据之后的图像边界。

也可以看看:

Summary

Constants

int DECODED_BLOCK_SIZE

解码块的字节大小。

int ENCODED_BLOCK_SIZE

编码块的字节大小。

int ETC1_RGB8_OES

由glCompressedTexImage2D的内部格式参数接受。

int ETC_PKM_HEADER_SIZE

PKM文件头的大小,以字节为单位。

Public constructors

ETC1()

Public methods

static void decodeBlock(Buffer in, Buffer out)

解码一个像素块。

static void decodeImage(Buffer in, Buffer out, int width, int height, int pixelSize, int stride)

解码整个图像。

static void encodeBlock(Buffer in, int validPixelMask, Buffer out)

编码一个像素块。

static void encodeImage(Buffer in, int width, int height, int pixelSize, int stride, Buffer out)

编码整个图像。

static void formatHeader(Buffer header, int width, int height)

格式化PKM标头

static int getEncodedDataSize(int width, int height)

返回编码图像数据的大小(不包括PKM头的大小)。

static int getHeight(Buffer header)

从PKM标题读取图像高度

static int getWidth(Buffer header)

从PKM标题读取图像宽度

static boolean isValid(Buffer header)

检查PKM标题是否格式正确。

Inherited methods

From class java.lang.Object

Constants

DECODED_BLOCK_SIZE

Added in API level 8
int DECODED_BLOCK_SIZE

解码块的字节大小。

常量值:48(0x00000030)

ENCODED_BLOCK_SIZE

Added in API level 8
int ENCODED_BLOCK_SIZE

编码块的字节大小。

常量值:8(0x00000008)

ETC1_RGB8_OES

Added in API level 8
int ETC1_RGB8_OES

由glCompressedTexImage2D的内部格式参数接受。

常量值:36196(0x00008d64)

ETC_PKM_HEADER_SIZE

Added in API level 8
int ETC_PKM_HEADER_SIZE

PKM文件头的大小,以字节为单位。

常量值:16(0x00000010)

Public constructors

ETC1

Added in API level 8
ETC1 ()

Public methods

decodeBlock

Added in API level 8
void decodeBlock (Buffer in, 
                Buffer out)

解码一个像素块。

Parameters
in Buffer: a native order direct buffer of size ENCODED_BLOCK_SIZE that contains the ETC1 compressed version of the data.
out Buffer: a native order direct buffer of size DECODED_BLOCK_SIZE that will receive the decoded data. The data represents a 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R value of pixel (x, y).

decodeImage

Added in API level 8
void decodeImage (Buffer in, 
                Buffer out, 
                int width, 
                int height, 
                int pixelSize, 
                int stride)

解码整个图像。

Parameters
in Buffer: native order direct buffer of the encoded data.
out Buffer: native order direct buffer of the image data. Will be written such that pixel (x,y) is at pIn + pixelSize * x + stride * y. Must be large enough to store entire image.
width int
height int
pixelSize int: must be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image.
stride int

encodeBlock

Added in API level 8
void encodeBlock (Buffer in, 
                int validPixelMask, 
                Buffer out)

编码一个像素块。

Parameters
in Buffer: a native order direct buffer of size DECODED_BLOCK_SIZE that represent a 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R value of pixel (x, y).
validPixelMask int: is a 16-bit mask where bit (1 << (x + y * 4)) indicates whether the corresponding (x,y) pixel is valid. Invalid pixel color values are ignored when compressing.
out Buffer: a native order direct buffer of size ENCODED_BLOCK_SIZE that receives the ETC1 compressed version of the data.

encodeImage

Added in API level 8
void encodeImage (Buffer in, 
                int width, 
                int height, 
                int pixelSize, 
                int stride, 
                Buffer out)

编码整个图像。

Parameters
in Buffer: a native order direct buffer of the image data. Formatted such that pixel (x,y) is at pIn + pixelSize * x + stride * y;
width int
height int
pixelSize int: must be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image.
stride int
out Buffer: a native order direct buffer of the encoded data. Must be large enough to store entire encoded image.

formatHeader

Added in API level 8
void formatHeader (Buffer header, 
                int width, 
                int height)

格式化PKM标头

Parameters
header Buffer: native order direct buffer of the header.
width int: the width of the image in pixels.
height int: the height of the image in pixels.

getEncodedDataSize

Added in API level 8
int getEncodedDataSize (int width, 
                int height)

返回编码图像数据的大小(不包括PKM头的大小)。

Parameters
width int
height int
Returns
int

getHeight

Added in API level 8
int getHeight (Buffer header)

从PKM标题读取图像高度

Parameters
header Buffer: native order direct buffer of the header.
Returns
int

getWidth

Added in API level 8
int getWidth (Buffer header)

从PKM标题读取图像宽度

Parameters
header Buffer: native order direct buffer of the header.
Returns
int

isValid

Added in API level 8
boolean isValid (Buffer header)

检查PKM标题是否格式正确。

Parameters
header Buffer: native order direct buffer of the header.
Returns
boolean

Hooray!