ImageConverter

Image converter helper.

Properties

Link copied to clipboard

This is used to hold the bytes of a frame when a rotate by 90 degrees is performed NOT THREAD SAFE

Functions

Link copied to clipboard
fun asBitmap(encoding: Bitmap.Config, buffer: ByteBuffer?, width: Int, height: Int): Bitmap?
fun asBitmap(encoding: Bitmap.Config, img: ByteArray, width: Int, height: Int): Bitmap?

Creates an android.graphics.Bitmap based on provided ByteArray that contains image.

fun asBitmap(format: EImagePixelFormat, buffer: ByteBuffer?, width: Int, height: Int): Bitmap?
fun asBitmap(format: EImagePixelFormat, buffer: ByteArray?, width: Int, height: Int): Bitmap?
fun asBitmap(format: Int, buffer: ByteBuffer?, width: Int, height: Int): Bitmap?

Converts a YUV 420 to ByteBuffer if possible.

Link copied to clipboard
fun encodeYUV420SP(yuv420sp: ByteArray, argb: IntArray, width: Int, height: Int)

Encodes provided argb buffer to NV21.

Link copied to clipboard
fun getNV21(bitmap: Bitmap): ByteArray

Converts provided android.graphics.Bitmap to ByteArray encoded as NV21

Link copied to clipboard

In native, Merges YUV planes of Image with 180 degrees rotation.

Link copied to clipboard

NOT THREAD SAFE Uses workBuffer to retain data while rotating

Link copied to clipboard
fun replaceColor(src: Bitmap?, map: Map<Int, Int>): Bitmap?
fun replaceColor(src: Bitmap?, fromColor: Int, targetColor: Int): Bitmap?

Replaces a color with another.

Link copied to clipboard
fun toAlpha8(src: Bitmap): Bitmap?

Convert the Bitmap to ALPHA_8. The old one will be recycled.

Link copied to clipboard

Merges Image.getPlanes if possible. The ByteBuffer is direct. See ByteBuffer.isDirect.

Link copied to clipboard
Link copied to clipboard