# HardwareBufferJni

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

*** ** * ** ***


```
@RequiresApi(value = 26)
@ExperimentalApi
class HardwareBufferJni : HardwareBufferJniWrapper
```

<br />

*** ** * ** ***

JNI methods for HardwareBuffer interaction.

## Summary

| ### Constants |
|---|---|
| `const https://developer.android.com/reference/kotlin/androidx/media3/effect/HardwareBufferJni!` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/HardwareBufferJni#INSTANCE()` |

| ### Public functions |
|---|---|
| `native https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/HardwareBufferJni#nativeBindEGLImage(int,long)(target: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, eglImageHandle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Binds an EGLImage to the specified texture target. |
| `native https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/HardwareBufferJni#nativeCopyBitmapToHardwareBuffer(android.graphics.Bitmap,android.hardware.HardwareBuffer)(bitmap: https://developer.android.com/reference/android/graphics/Bitmap.html!, hb: https://developer.android.com/reference/android/hardware/HardwareBuffer.html!)` Copies a `https://developer.android.com/reference/android/graphics/Bitmap.html` to a `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`. |
| `native https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/HardwareBufferJni#nativeCopyHardwareBufferToHardwareBuffer(android.hardware.HardwareBuffer,android.hardware.HardwareBuffer)( srcHb: https://developer.android.com/reference/android/hardware/HardwareBuffer.html!, dstHb: https://developer.android.com/reference/android/hardware/HardwareBuffer.html! )` Copies the contents of a source `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` to a destination `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`. |
| `native https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/HardwareBufferJni#nativeCreateEglImageFromHardwareBuffer(long,android.hardware.HardwareBuffer)( displayHandle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, hardwareBuffer: https://developer.android.com/reference/android/hardware/HardwareBuffer.html! )` Creates an EGLImage from a `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`. |
| `native https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/effect/HardwareBufferJni#nativeDestroyEGLImage(long,long)(displayHandle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, imageHandle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Destroys an EGLImage. |

### Inherited functions

From [androidx.media3.common.video.HardwareBufferNativeHelpers](https://developer.android.com/reference/kotlin/androidx/media3/common/video/HardwareBufferNativeHelpers) `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 26)
https://developer.android.com/reference/kotlin/androidx/media3/common/video/HardwareBufferNativeHelpers#nativeCopyHardwareBufferToHardwareBuffer(android.hardware.HardwareBuffer,android.hardware.HardwareBuffer)(
srcHb: https://developer.android.com/reference/android/hardware/HardwareBuffer.html!,
dstHb: https://developer.android.com/reference/android/hardware/HardwareBuffer.html!
)`

Copies the contents of a source `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` to a destination `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`.

## Constants

### INSTANCE

```
const val INSTANCE: HardwareBufferJni!
```

## Public functions

### nativeBindEGLImage

```
native fun nativeBindEGLImage(target: Int, eglImageHandle: Long): Boolean
```

Binds an EGLImage to the specified texture target. Returns whether the binding is successful.

### nativeCopyBitmapToHardwareBuffer

```
native fun nativeCopyBitmapToHardwareBuffer(bitmap: Bitmap!, hb: HardwareBuffer!): Boolean
```

Copies a `https://developer.android.com/reference/android/graphics/Bitmap.html` to a `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`. Returns whether the copy is successful.

The destination `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` must have `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#USAGE_CPU_WRITE_OFTEN` usage.

The source `https://developer.android.com/reference/android/graphics/Bitmap.Config.html` must match the destination `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#getFormat()`, and be either `https://developer.android.com/reference/android/graphics/Bitmap.Config.html#ARGB_8888` and `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#RGBA_8888` or `https://developer.android.com/reference/android/graphics/Bitmap.Config.html#RGBA_1010102` and `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#RGBA_1010102`.

### nativeCopyHardwareBufferToHardwareBuffer

```
native fun nativeCopyHardwareBufferToHardwareBuffer(
    srcHb: HardwareBuffer!,
    dstHb: HardwareBuffer!
): Boolean
```

Copies the contents of a source `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` to a destination `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`. Returns whether the copy is successful.

The source `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` must have `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#USAGE_CPU_READ_OFTEN` usage, and the destination `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` must have `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#USAGE_CPU_WRITE_OFTEN` usage.

The formats of the source and destination buffers must match, and be either `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#RGBA_8888` or `https://developer.android.com/reference/android/hardware/HardwareBuffer.html#RGBA_1010102`.

### nativeCreateEglImageFromHardwareBuffer

```
native fun nativeCreateEglImageFromHardwareBuffer(
    displayHandle: Long,
    hardwareBuffer: HardwareBuffer!
): Long
```

Creates an EGLImage from a `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`.

### nativeDestroyEGLImage

```
native fun nativeDestroyEGLImage(displayHandle: Long, imageHandle: Long): Boolean
```

Destroys an EGLImage. Returns whether the deletion is successful.