CameraImageUtils

Util methods to process Camera images

Functions

Link copied to clipboard
fun bitmapToNv21(src: Bitmap, width: Int, height: Int): ByteArray

Converts Android Bitmap image to NV21 format.

Link copied to clipboard
fun computeCropRectFromAspectRatio(sourceSize: Size, aspectRatio: Rational): Rect?

Calculates crop rect with the specified aspect ratio on the given size. Assuming the rect is at the center of the source.

Link copied to clipboard

Crops byte array with given android.graphics.Rect.

Link copied to clipboard
fun imageToJpegByteArray(image: <Error class: unknown class>): ByteArray?

android.media.Image to JPEG byte array.

Link copied to clipboard
fun isAspectRatioValid(aspectRatio: Rational?): Boolean

True if the given aspect ratio is meaningful.

fun isAspectRatioValid(sourceSize: Size, aspectRatio: Rational?): Boolean

True if the given aspect ratio is meaningful and has effect on the given size.

Link copied to clipboard
fun nv21ToJpeg(nv21: ByteArray, width: Int, height: Int, cropRect: Rect?): ByteArray
Link copied to clipboard
fun nv21ToYuv420888(nv21: ByteArray, width: Int, height: Int): ByteArray
Link copied to clipboard
fun rotate(rational: Rational, rotation: Int): Rational

Rotate rational by rotation value, which inverse it if the degree is 90 or 270.

Link copied to clipboard
fun yuv420888toNv21(image: <Error class: unknown class>): ByteArray