# HardwareBufferNativeHelpers

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

*** ** * ** ***


```
@ExperimentalApi
interface HardwareBufferNativeHelpers
```

<br />

Known direct subclasses [FakeHardwareBufferNativeHelpers](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeHardwareBufferNativeHelpers), [HardwareBufferJniWrapper](https://developer.android.com/reference/kotlin/androidx/media3/effect/HardwareBufferJniWrapper)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeHardwareBufferNativeHelpers` | Fake class to simulate `https://developer.android.com/reference/kotlin/androidx/media3/common/video/HardwareBufferNativeHelpers`. |
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/HardwareBufferJniWrapper` | Wrapper for `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` JNI methods. |

Known indirect subclasses [HardwareBufferJni](https://developer.android.com/reference/kotlin/androidx/media3/effect/HardwareBufferJni)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/effect/HardwareBufferJni` | JNI methods for HardwareBuffer interaction. |

*** ** * ** ***

Wrapper for `https://developer.android.com/reference/android/hardware/HardwareBuffer.html` JNI methods.

## Summary

| ### Public functions |
|---|---|
| `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#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`. |
| `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`. |

## Public functions

### nativeCopyBitmapToHardwareBuffer

```
@RequiresApi(value = 26)
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`.

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`.

| Parameters |
|---|---|
| `bitmap: https://developer.android.com/reference/android/graphics/Bitmap.html!` | The source bitmap. |
| `hb: https://developer.android.com/reference/android/hardware/HardwareBuffer.html!` | The destination hardware buffer. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the copy is successful. |

### nativeCopyHardwareBufferToHardwareBuffer

```
@RequiresApi(value = 26)
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`.

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`.

| Parameters |
|---|---|
| `srcHb: https://developer.android.com/reference/android/hardware/HardwareBuffer.html!` | The source hardware buffer. |
| `dstHb: https://developer.android.com/reference/android/hardware/HardwareBuffer.html!` | The destination hardware buffer. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the copy is successful. |