I have the following code for onPreviewFrame() Callback. It is now able to save the data as a JPEG file and I can view it in a browser but not in Windows Picture Viewer. Is there something wrong with my code?
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){
}
Thanks,
artsylar
My code is working now. I don’t know what happened yesterday but the only difference is I’m using adb command now to pull files and yesterday I was using the Eclipse File Explorer.
But just in case there is a better way to write this code, please let me know.