# HardwareBufferJniWrapper

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/HardwareBufferJniWrapper.kt+class:androidx.media3.effect.HardwareBufferJniWrapper)

*** ** * ** ***


```
@RequiresApi(value = 26)
@ExperimentalApi
public interface HardwareBufferJniWrapper extends HardwareBufferNativeHelpers
```

<br />

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

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

*** ** * ** ***

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

## Summary

| ### Public methods |
|---|---|
| `abstract boolean` | `https://developer.android.com/reference/androidx/media3/effect/HardwareBufferJniWrapper#nativeBindEGLImage(kotlin.Int,kotlin.Long)(int target, long eglImageHandle)` Binds an EGLImage to the specified texture target. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/media3/effect/HardwareBufferJniWrapper#nativeCopyBitmapToHardwareBuffer(android.graphics.Bitmap,android.hardware.HardwareBuffer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Bitmap.html bitmap, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/HardwareBuffer.html hb )` Copies a `https://developer.android.com/reference/android/graphics/Bitmap.html` to a `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/media3/effect/HardwareBufferJniWrapper#nativeCopyHardwareBufferToHardwareBuffer(android.hardware.HardwareBuffer,android.hardware.HardwareBuffer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/HardwareBuffer.html srcHb, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/HardwareBuffer.html dstHb )` 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`. |
| `abstract long` | `https://developer.android.com/reference/androidx/media3/effect/HardwareBufferJniWrapper#nativeCreateEglImageFromHardwareBuffer(kotlin.Long,android.hardware.HardwareBuffer)( long displayHandle, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/HardwareBuffer.html hardwareBuffer )` Creates an EGLImage from a `https://developer.android.com/reference/android/hardware/HardwareBuffer.html`. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/media3/effect/HardwareBufferJniWrapper#nativeDestroyEGLImage(kotlin.Long,kotlin.Long)(long displayHandle, long imageHandle)` Destroys an EGLImage. |

## Public methods

### nativeBindEGLImage

```
abstract boolean nativeBindEGLImage(int target, long eglImageHandle)
```

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

### nativeCopyBitmapToHardwareBuffer

```
abstract boolean nativeCopyBitmapToHardwareBuffer(
    @NonNull Bitmap bitmap,
    @NonNull HardwareBuffer hb
)
```

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

```
abstract boolean nativeCopyHardwareBufferToHardwareBuffer(
    @NonNull HardwareBuffer srcHb,
    @NonNull HardwareBuffer dstHb
)
```

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

```
abstract long nativeCreateEglImageFromHardwareBuffer(
    long displayHandle,
    @NonNull HardwareBuffer hardwareBuffer
)
```

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

### nativeDestroyEGLImage

```
abstract boolean nativeDestroyEGLImage(long displayHandle, long imageHandle)
```

Destroys an EGLImage. Returns whether the deletion is successful.