# ImageReaderSurfaceHolder

Artifact: [androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/ImageReaderSurfaceHolder.java+class:androidx.media3.test.utils.ImageReaderSurfaceHolder)

*** ** * ** ***


```
@ExperimentalApi
class ImageReaderSurfaceHolder : SurfaceHolder, AutoCloseable
```

<br />

*** ** * ** ***

An implementation of `https://developer.android.com/reference/android/view/SurfaceHolder.html` which is backed by an `https://developer.android.com/reference/android/media/ImageReader.html`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#ImageReaderSurfaceHolder(android.os.Handler)(handler: https://developer.android.com/reference/android/os/Handler.html!)` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#addCallback(android.view.SurfaceHolder.Callback)(callback: https://developer.android.com/reference/android/view/SurfaceHolder.Callback.html!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#close()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#drainSurface()()` Drains the `https://developer.android.com/reference/android/media/ImageReader.html` so more frames can be queued to the `https://developer.android.com/reference/android/view/Surface.html`. |
| `https://developer.android.com/reference/android/view/Surface.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#getSurface()()` |
| `https://developer.android.com/reference/android/graphics/Rect.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#getSurfaceFrame()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#isCreating()()` |
| `https://developer.android.com/reference/android/graphics/Canvas.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#lockCanvas()()` |
| `https://developer.android.com/reference/android/graphics/Canvas.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#lockCanvas(android.graphics.Rect)(dirty: https://developer.android.com/reference/android/graphics/Rect.html!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#removeCallback(android.view.SurfaceHolder.Callback)(callback: https://developer.android.com/reference/android/view/SurfaceHolder.Callback.html!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#setFixedSize(int,int)(width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#setFormat(int)(format: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#setKeepScreenOn(boolean)(screenOn: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#setSizeFromLayout()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#setType(int)(type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` **This function is deprecated.** |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#unlockCanvasAndPost(android.graphics.Canvas)(canvas: https://developer.android.com/reference/android/graphics/Canvas.html!)` |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/android/media/ImageReader.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ImageReaderSurfaceHolder#imageReader()` |

| ### Inherited Constants |
|---|
| From [android.view.SurfaceHolder](https://developer.android.com/reference/android/view/SurfaceHolder.html) |---|---| | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/android/view/SurfaceHolder.html#SURFACE_TYPE_GPU = 2` **This property is deprecated.** | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/android/view/SurfaceHolder.html#SURFACE_TYPE_HARDWARE = 1` **This property is deprecated.** | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/android/view/SurfaceHolder.html#SURFACE_TYPE_NORMAL = 0` **This property is deprecated.** | | `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/android/view/SurfaceHolder.html#SURFACE_TYPE_PUSH_BUFFERS = 3` **This property is deprecated.** | |

| ### Inherited functions |
|---|
| From [android.view.SurfaceHolder](https://developer.android.com/reference/android/view/SurfaceHolder.html) |---|---| | `https://developer.android.com/reference/android/graphics/Canvas.html!` | `https://developer.android.com/reference/android/view/SurfaceHolder.html#lockHardwareCanvas()()` | |

## Public constructors

### ImageReaderSurfaceHolder

```
ImageReaderSurfaceHolder(handler: Handler!)
```

## Public functions

### addCallback

```
fun addCallback(callback: SurfaceHolder.Callback!): Unit
```

### close

```
fun close(): Unit
```

### drainSurface

```
fun drainSurface(): Unit
```

Drains the `https://developer.android.com/reference/android/media/ImageReader.html` so more frames can be queued to the `https://developer.android.com/reference/android/view/Surface.html`.

### getSurface

```
fun getSurface(): Surface!
```

### getSurfaceFrame

```
fun getSurfaceFrame(): Rect!
```

### isCreating

```
fun isCreating(): Boolean
```

### lockCanvas

```
fun lockCanvas(): Canvas!
```

### lockCanvas

```
fun lockCanvas(dirty: Rect!): Canvas!
```

### removeCallback

```
fun removeCallback(callback: SurfaceHolder.Callback!): Unit
```

### setFixedSize

```
fun setFixedSize(width: Int, height: Int): Unit
```

### setFormat

```
fun setFormat(format: Int): Unit
```

### setKeepScreenOn

```
fun setKeepScreenOn(screenOn: Boolean): Unit
```

### setSizeFromLayout

```
fun setSizeFromLayout(): Unit
```

### setType

```
fun setType(type: Int): Unit
```

> [!CAUTION]
> **This function is deprecated.**   

### unlockCanvasAndPost

```
fun unlockCanvasAndPost(canvas: Canvas!): Unit
```

## Public properties

### imageReader

```
val imageReader: ImageReader?
```