Package 

Class LibYuv


  • 
    public final class LibYuv
    
                        

    LibYuv:基于Google的libyuv编译封装的YUV转换类工具库,主要用途是在各种YUV与RGB之间进行相互转换、裁减、旋转、缩放、镜像等。

    常用的方法如下:

    将I420数据转换为指定格式的数据:convertFromI420

    将指定格式的数据转换为I420数据: convertToI420

    YUV转I420:yuvToI420

    将指定格式的数据进行旋转: rotate

    将指定格式的数据进行缩放: scale

    将指定格式的数据进行裁减: crop

    将指定格式的数据进行镜像翻转: mirror

    • Method Summary

      Modifier and Type Method Description
      static Array<byte> imageToI420(Image image, int degrees) 将Image转换为I420
      static Array<byte> nv21ToI420(@NonNull() Array<byte> nv21Data, int width, int height) NV21转I420
      static Array<byte> i420ToNv21(@NonNull() Array<byte> i420Data, int width, int height) I420转NV21
      static Array<byte> rotate(@NonNull() Array<byte> srcData, int width, int height, int degrees, @NonNull() FourCC fourcc) 将指定格式的数据进行旋转
      static Array<byte> scale(@NonNull() Array<byte> srcData, int width, int height, int dstWidth, int dstHeight, @NonNull() FourCC fourcc, int filterMode) 将指定格式的数据进行缩放
      static Array<byte> scale(@NonNull() Array<byte> srcData, int width, int height, int dstWidth, int dstHeight, int dstSize, @NonNull() FourCC fourcc, int filterMode) 将指定格式的数据进行缩放
      static Array<byte> crop(@NonNull() Array<byte> srcData, int width, int height, @NonNull() Rect cropRect, @NonNull() FourCC fourcc) 将指定格式的数据进行裁减
      static Array<byte> crop(@NonNull() Array<byte> srcData, int width, int height, int cropX, int cropY, int cropWidth, int cropHeight, @NonNull() FourCC fourcc) 将指定格式的数据进行裁减
      static Array<byte> crop(@NonNull() Array<byte> srcData, int width, int height, int cropX, int cropY, int cropWidth, int cropHeight, int dstSize, @NonNull() FourCC fourcc) 将指定格式的数据进行裁减
      static Array<byte> mirror(@NonNull() Array<byte> srcData, int width, int height, @NonNull() FourCC fourcc) 将指定格式的数据进行镜像翻转
      static Array<byte> convertFromI420(@NonNull() Array<byte> i420Data, int width, int height, @NonNull() FourCC fourcc) 将I420数据转换为指定格式的数据
      static Array<byte> convertFromI420(@NonNull() Array<byte> i420Data, int width, int height, int dstSize, @NonNull() FourCC fourcc) 将I420数据转换为指定格式的数据
      static Array<byte> convertToI420(@NonNull() Array<byte> srcData, int width, int height, @NonNull() FourCC fourcc) 将指定格式的数据转换为I420数据
      static Array<byte> convertToI420(@NonNull() Array<byte> srcData, int width, int height, int degrees, @NonNull() FourCC fourcc) 将指定格式的数据转换为I420数据
      static Array<byte> convertToI420(@NonNull() Array<byte> srcData, int width, int height, @NonNull() Rect cropRect, int degrees, @NonNull() FourCC fourcc) 将指定格式的数据转换为I420数据
      static Array<byte> convertToI420(@NonNull() Array<byte> srcData, int width, int height, int cropX, int cropY, int cropWidth, int cropHeight, int degrees, @NonNull() FourCC fourcc) 将指定格式的数据转换为I420数据
      static Array<byte> i420Rotate(@NonNull() Array<byte> srcI420Data, int width, int height, int degrees) I420旋转
      static Array<byte> i420Mirror(@NonNull() Array<byte> srcI420Data, int width, int height) I420镜像
      static Array<byte> i420Scale(@NonNull() Array<byte> srcI420Data, int width, int height, int dstWidth, int dstHeight, int filterMode) I420缩放
      static Array<byte> i420Crop(@NonNull() Array<byte> srcI420Data, int width, int height, int cropX, int cropY, int cropWidth, int cropHeight) I420裁减
      static Array<byte> yuvToI420(ByteBuffer srcYData, ByteBuffer srcUData, ByteBuffer srcVData, int yStride, int uStride, int vStride, int uvPixelStride, int width, int height, int degrees) YUV转I420
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • imageToI420

        @NonNull() static Array<byte> imageToI420(Image image, int degrees)

        将Image转换为I420

        Parameters:
        image - 图像;Image
        degrees - 需要旋转的角度
      • nv21ToI420

        @NonNull() static Array<byte> nv21ToI420(@NonNull() Array<byte> nv21Data, int width, int height)

        NV21转I420

        Parameters:
        nv21Data - 源NV21数据
        width - 图像宽度
        height - 图像高度
      • i420ToNv21

        @NonNull() static Array<byte> i420ToNv21(@NonNull() Array<byte> i420Data, int width, int height)

        I420转NV21

        Parameters:
        i420Data - 源I420数据
        width - 图像宽度
        height - 图像高度
      • rotate

        @NonNull() static Array<byte> rotate(@NonNull() Array<byte> srcData, int width, int height, int degrees, @NonNull() FourCC fourcc)

        将指定格式的数据进行旋转

        Parameters:
        srcData - 源数据
        width - 图像宽度
        height - 图像高度
        degrees - 需要旋转的角度;RotationMode
        fourcc - 指定数据格式;FourCC
      • scale

        @NonNull() static Array<byte> scale(@NonNull() Array<byte> srcData, int width, int height, int dstWidth, int dstHeight, @NonNull() FourCC fourcc, int filterMode)

        将指定格式的数据进行缩放

        Parameters:
        srcData - 源数据
        width - 图像宽度
        height - 图像高度
        dstWidth - 目标宽
        dstHeight - 目标高
        fourcc - 指定数据格式;FourCC
        filterMode - 压缩过滤模式;FilterMode
      • scale

        @NonNull() static Array<byte> scale(@NonNull() Array<byte> srcData, int width, int height, int dstWidth, int dstHeight, int dstSize, @NonNull() FourCC fourcc, int filterMode)

        将指定格式的数据进行缩放

        Parameters:
        srcData - 源数据
        width - 图像宽度
        height - 图像高度
        dstWidth - 目标宽
        dstHeight - 目标高
        dstSize - 目标数据大小
        fourcc - 指定数据格式;FourCC
        filterMode - 压缩过滤模式;FilterMode
      • crop

        @NonNull() static Array<byte> crop(@NonNull() Array<byte> srcData, int width, int height, @NonNull() Rect cropRect, @NonNull() FourCC fourcc)

        将指定格式的数据进行裁减

        Parameters:
        srcData - 源数据
        width - 图像宽度
        height - 图像高度
        cropRect - 裁减的矩形区域
        fourcc - 指定数据格式;FourCC
      • crop

        @NonNull() static Array<byte> crop(@NonNull() Array<byte> srcData, int width, int height, int cropX, int cropY, int cropWidth, int cropHeight, @NonNull() FourCC fourcc)

        将指定格式的数据进行裁减

        Parameters:
        srcData - 源数据
        width - 图像宽度
        height - 图像高度
        cropX - 裁减起始点X坐标
        cropY - 裁减起始点Y坐标
        cropWidth - 裁减的宽度
        cropHeight - 裁减的高度
        fourcc - 指定数据格式;FourCC
      • crop

        @NonNull() static Array<byte> crop(@NonNull() Array<byte> srcData, int width, int height, int cropX, int cropY, int cropWidth, int cropHeight, int dstSize, @NonNull() FourCC fourcc)

        将指定格式的数据进行裁减

        Parameters:
        srcData - 源数据
        width - 图像宽度
        height - 图像高度
        cropX - 裁减起始点X坐标
        cropY - 裁减起始点Y坐标
        cropWidth - 裁减的宽度
        cropHeight - 裁减的高度
        dstSize - 目标数据大小
        fourcc - 指定数据格式;FourCC
      • mirror

        @NonNull() static Array<byte> mirror(@NonNull() Array<byte> srcData, int width, int height, @NonNull() FourCC fourcc)

        将指定格式的数据进行镜像翻转

        Parameters:
        srcData - 源数据
        width - 图像宽度
        height - 图像高度
        fourcc - 指定数据格式;FourCC
      • convertFromI420

        @NonNull() static Array<byte> convertFromI420(@NonNull() Array<byte> i420Data, int width, int height, @NonNull() FourCC fourcc)

        将I420数据转换为指定格式的数据

        Parameters:
        i420Data - 源I420数据
        width - 图像宽度
        height - 图像高度
        fourcc - 指定数据格式;FourCC
      • convertFromI420

        @NonNull() static Array<byte> convertFromI420(@NonNull() Array<byte> i420Data, int width, int height, int dstSize, @NonNull() FourCC fourcc)

        将I420数据转换为指定格式的数据

        Parameters:
        i420Data - 源I420数据
        width - 图像宽度
        height - 图像高度
        dstSize - 目标数据占用字节大小
        fourcc - 指定数据格式;FourCC
      • convertToI420

        @NonNull() static Array<byte> convertToI420(@NonNull() Array<byte> srcData, int width, int height, @NonNull() FourCC fourcc)

        将指定格式的数据转换为I420数据

        Parameters:
        srcData - 源数据
        width - 图像宽度
        height - 图像高度
        fourcc - 指定数据格式;FourCC
      • convertToI420

        @NonNull() static Array<byte> convertToI420(@NonNull() Array<byte> srcData, int width, int height, int degrees, @NonNull() FourCC fourcc)

        将指定格式的数据转换为I420数据

        Parameters:
        srcData - 源数据
        width - 图像宽度
        height - 图像高度
        degrees - 需要旋转的角度;RotationMode
        fourcc - 指定数据格式;FourCC
      • convertToI420

        @NonNull() static Array<byte> convertToI420(@NonNull() Array<byte> srcData, int width, int height, @NonNull() Rect cropRect, int degrees, @NonNull() FourCC fourcc)

        将指定格式的数据转换为I420数据

        Parameters:
        srcData - 源数据
        width - 图像宽度
        height - 图像高度
        cropRect - 裁减的矩形
        degrees - 需要旋转的角度;RotationMode
        fourcc - 指定数据格式;FourCC
      • convertToI420

        @NonNull() static Array<byte> convertToI420(@NonNull() Array<byte> srcData, int width, int height, int cropX, int cropY, int cropWidth, int cropHeight, int degrees, @NonNull() FourCC fourcc)

        将指定格式的数据转换为I420数据

        Parameters:
        srcData - 源数据
        width - 图像宽度
        height - 图像高度
        cropX - 裁减起始点X坐标
        cropY - 裁减起始点Y坐标
        cropWidth - 裁减的宽度
        cropHeight - 裁减的高度
        degrees - 需要旋转的角度;RotationMode
        fourcc - 指定数据格式;FourCC
      • i420Rotate

        @NonNull() static Array<byte> i420Rotate(@NonNull() Array<byte> srcI420Data, int width, int height, int degrees)

        I420旋转

        Parameters:
        srcI420Data - 源I420数据
        width - 图像宽度
        height - 图像高度
        degrees - 需要旋转的角度;RotationMode
      • i420Mirror

        @NonNull() static Array<byte> i420Mirror(@NonNull() Array<byte> srcI420Data, int width, int height)

        I420镜像

        Parameters:
        srcI420Data - 源I420数据
        width - 图像宽度
        height - 图像高度
      • i420Scale

        @NonNull() static Array<byte> i420Scale(@NonNull() Array<byte> srcI420Data, int width, int height, int dstWidth, int dstHeight, int filterMode)

        I420缩放

        Parameters:
        srcI420Data - 源I420数据
        width - 图像宽度
        height - 图像高度
        dstWidth - 目标宽
        dstHeight - 目标高
        filterMode - 压缩过滤模式;FilterMode
      • i420Crop

        @NonNull() static Array<byte> i420Crop(@NonNull() Array<byte> srcI420Data, int width, int height, int cropX, int cropY, int cropWidth, int cropHeight)

        I420裁减

        Parameters:
        srcI420Data - 源I420数据
        width - 图像宽度
        height - 图像高度
        cropX - 裁减起始点X坐标
        cropY - 裁减起始点Y坐标
        cropWidth - 裁减的宽度
        cropHeight - 裁减的高度
      • yuvToI420

        @NonNull() static Array<byte> yuvToI420(ByteBuffer srcYData, ByteBuffer srcUData, ByteBuffer srcVData, int yStride, int uStride, int vStride, int uvPixelStride, int width, int height, int degrees)

        YUV转I420

        Parameters:
        srcYData - 源Y数据
        srcUData - 源U数据
        srcVData - 源V数据
        yStride - 源Y跨距
        uStride - 源U跨距
        vStride - 源V跨距
        uvPixelStride - UV像素跨距
        width - 图像宽度
        height - 图像高度
        degrees - 需要旋转的角度;RotationMode