/**
* yuv转换图像
* @param frameData
* @param yuvFormat
* @param prevWidth
* @param prevHeight
* @param quality
* @return
*/
public static Bitmap yuv2Img(byte[] frameData, int yuvFormat, int prevWidth, int prevHeight,
int quality) {
Long start = System.currentTimeMillis();
Bitmap img = null;
try {
YuvImage image = new YuvImage(frameData, yuvFormat, prevWidth, prevHeight, null);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.RGB_565;
if (image != null) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compressToJpeg(new Rect(0, 0, prevWidth, prevHeight), quality, stream);
img = BitmapFactory.decodeByteArray(stream.toByteArray(), 0, stream.size(), options);
stream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return img;
}
ImgUtil.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:PreRect
作者:
评论列表
文章目录