-
public final class LibYuvLibYuv:基于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 -
-
Method Detail
-
imageToI420
@NonNull() static Array<byte> imageToI420(Image image, int degrees)
将Image转换为I420
- Parameters:
image- 图像;Imagedegrees- 需要旋转的角度
-
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- 需要旋转的角度;RotationModefourcc- 指定数据格式;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- 指定数据格式;FourCCfilterMode- 压缩过滤模式;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- 指定数据格式;FourCCfilterMode- 压缩过滤模式;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- 需要旋转的角度;RotationModefourcc- 指定数据格式;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- 需要旋转的角度;RotationModefourcc- 指定数据格式;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- 需要旋转的角度;RotationModefourcc- 指定数据格式;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
-
-
-
-