Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/opengl/ETC1#constants) \| [Ctors](https://developer.android.com/reference/android/opengl/ETC1#pubctors) \| [Methods](https://developer.android.com/reference/android/opengl/ETC1#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/opengl/ETC1#inhmethods)

# ETC1

*** ** * ** ***


`
public


class
ETC1
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.opengl.ETC1 |

<br />

*** ** * ** ***

Methods for encoding and decoding ETC1 textures.


The standard for the ETC1 texture format can be found at
http://www.khronos.org/registry/gles/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt


The PKM file format is of a 16-byte header that describes the image bounds
followed by the encoded ETC1 texture data.

<br />

**See also:**

- `https://developer.android.com/reference/android/opengl/ETC1Util`

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/opengl/ETC1#DECODED_BLOCK_SIZE` Size in bytes of a decoded block. |
| `int` | `https://developer.android.com/reference/android/opengl/ETC1#ENCODED_BLOCK_SIZE` Size in bytes of an encoded block. |
| `int` | `https://developer.android.com/reference/android/opengl/ETC1#ETC1_RGB8_OES` Accepted by the internalformat parameter of glCompressedTexImage2D. |
| `int` | `https://developer.android.com/reference/android/opengl/ETC1#ETC_PKM_HEADER_SIZE` Size of a PKM file header, in bytes. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/opengl/ETC1#ETC1()() ` |

| ### Public methods ||
|---|---|
| ` static void` | ` https://developer.android.com/reference/android/opengl/ETC1#decodeBlock(java.nio.Buffer,%20java.nio.Buffer)(https://developer.android.com/reference/java/nio/Buffer in, https://developer.android.com/reference/java/nio/Buffer out) ` Decode a block of pixels. |
| ` static void` | ` https://developer.android.com/reference/android/opengl/ETC1#decodeImage(java.nio.Buffer,%20java.nio.Buffer,%20int,%20int,%20int,%20int)(https://developer.android.com/reference/java/nio/Buffer in, https://developer.android.com/reference/java/nio/Buffer out, int width, int height, int pixelSize, int stride) ` Decode an entire image. |
| ` static void` | ` https://developer.android.com/reference/android/opengl/ETC1#encodeBlock(java.nio.Buffer,%20int,%20java.nio.Buffer)(https://developer.android.com/reference/java/nio/Buffer in, int validPixelMask, https://developer.android.com/reference/java/nio/Buffer out) ` Encode a block of pixels. |
| ` static void` | ` https://developer.android.com/reference/android/opengl/ETC1#encodeImage(java.nio.Buffer,%20int,%20int,%20int,%20int,%20java.nio.Buffer)(https://developer.android.com/reference/java/nio/Buffer in, int width, int height, int pixelSize, int stride, https://developer.android.com/reference/java/nio/Buffer out) ` Encode an entire image. |
| ` static void` | ` https://developer.android.com/reference/android/opengl/ETC1#formatHeader(java.nio.Buffer,%20int,%20int)(https://developer.android.com/reference/java/nio/Buffer header, int width, int height) ` Format a PKM header |
| ` static int` | ` https://developer.android.com/reference/android/opengl/ETC1#getEncodedDataSize(int,%20int)(int width, int height) ` Return the size of the encoded image data (does not include size of PKM header). |
| ` static int` | ` https://developer.android.com/reference/android/opengl/ETC1#getHeight(java.nio.Buffer)(https://developer.android.com/reference/java/nio/Buffer header) ` Read the image height from a PKM header |
| ` static int` | ` https://developer.android.com/reference/android/opengl/ETC1#getWidth(java.nio.Buffer)(https://developer.android.com/reference/java/nio/Buffer header) ` Read the image width from a PKM header |
| ` static boolean` | ` https://developer.android.com/reference/android/opengl/ETC1#isValid(java.nio.Buffer)(https://developer.android.com/reference/java/nio/Buffer header) ` Check if a PKM header is correctly formatted. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Constants

### DECODED_BLOCK_SIZE

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int DECODED_BLOCK_SIZE
```

Size in bytes of a decoded block.

<br />

Constant Value:

48
(0x00000030)


### ENCODED_BLOCK_SIZE

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int ENCODED_BLOCK_SIZE
```

Size in bytes of an encoded block.

<br />

Constant Value:

8
(0x00000008)


### ETC1_RGB8_OES

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int ETC1_RGB8_OES
```

Accepted by the internalformat parameter of glCompressedTexImage2D.

<br />

Constant Value:

36196
(0x00008d64)


### ETC_PKM_HEADER_SIZE

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int ETC_PKM_HEADER_SIZE
```

Size of a PKM file header, in bytes.

<br />

Constant Value:

16
(0x00000010)


## Public constructors

### ETC1

```
public ETC1 ()
```

<br />

<br />

## Public methods

### decodeBlock

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static void decodeBlock (Buffer in, 
                Buffer out)
```

Decode a block of pixels.

<br />

| Parameters ||
|---|---|
| `in` | `Buffer`: a native order direct buffer of size ENCODED_BLOCK_SIZE that contains the ETC1 compressed version of the data. <br /> |
| `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). <br /> |

### decodeImage

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

Decode an entire image.

<br />

| Parameters ||
|---|---|
| `in` | `Buffer`: native order direct buffer of the encoded data. <br /> |
| `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. <br /> |
| `width` | `int` <br /> |
| `height` | `int` <br /> |
| `pixelSize` | `int`: must be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image. <br /> |
| `stride` | `int` <br /> |

### encodeBlock

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

Encode a block of pixels.

<br />

| 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). <br /> |
| `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. <br /> |
| `out` | `Buffer`: a native order direct buffer of size ENCODED_BLOCK_SIZE that receives the ETC1 compressed version of the data. <br /> |

### encodeImage

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

Encode an entire image.

<br />

| 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; <br /> |
| `width` | `int` <br /> |
| `height` | `int` <br /> |
| `pixelSize` | `int`: must be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image. <br /> |
| `stride` | `int` <br /> |
| `out` | `Buffer`: a native order direct buffer of the encoded data. Must be large enough to store entire encoded image. <br /> |

### formatHeader

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

Format a PKM header

<br />

| Parameters ||
|---|---|
| `header` | `Buffer`: native order direct buffer of the header. <br /> |
| `width` | `int`: the width of the image in pixels. <br /> |
| `height` | `int`: the height of the image in pixels. <br /> |

### getEncodedDataSize

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getEncodedDataSize (int width, 
                int height)
```

Return the size of the encoded image data (does not include size of PKM header).

<br />

| Parameters ||
|---|---|
| `width` | `int` <br /> |
| `height` | `int` <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### getHeight

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getHeight (Buffer header)
```

Read the image height from a PKM header

<br />

| Parameters ||
|---|---|
| `header` | `Buffer`: native order direct buffer of the header. <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### getWidth

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getWidth (Buffer header)
```

Read the image width from a PKM header

<br />

| Parameters ||
|---|---|
| `header` | `Buffer`: native order direct buffer of the header. <br /> |

| Returns ||
|---|---|
| `int` | <br /> |

### isValid

Added in [API level 8](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isValid (Buffer header)
```

Check if a PKM header is correctly formatted.

<br />

| Parameters ||
|---|---|
| `header` | `Buffer`: native order direct buffer of the header. <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |