3
我對以下代碼適用於onPreviewFrame()回調。現在可以將數據保存爲JPEG文件,並且可以在瀏覽器中查看,但不能在Windows Picture Viewer中查看。我的代碼有問題嗎?Android(onPreviewFrame):將NV21數據保存爲JPEG文件
YuvImage im = new YuvImage(data, ImageFormat.NV21, size.width,
size.height, null);
Rect r = new Rect(0,0,size.width,size.height);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
im.compressToJpeg(r, parameters.getJpegQuality(), baos);
try{
FileOutputStream output = new FileOutputStream(String.format(
"/sdcard/%s_%d.jpg", strPrevCBType, System.currentTimeMillis()));
output.write(baos.toByteArray());
output.flush();
output.close();
}catch(FileNotFoundException e){
}catch(IOException e){
}
感謝,
artsylar