标签:android blog class code java c
// 创建保存照片文件夹 private void CreateFileJPG() { File file = new File("/sdcard/image"); if (!file.exists()) { try { file.mkdirs(); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } }
/** * 拍照保存图片 * */ public void saveMyBitmap() { FileOutputStream outStream = null; try { YuvImage yuvimage = new YuvImage(dataJPG, ImageFormat.NV21, cameraJPG.getParameters().getPreviewSize().width, cameraJPG .getParameters().getPreviewSize().height, null); ByteArrayOutputStream baos = new ByteArrayOutputStream(); yuvimage.compressToJpeg(new Rect(0, 0, cameraJPG.getParameters() .getPreviewSize().width, cameraJPG.getParameters() .getPreviewSize().height), 80, baos); outStream = new FileOutputStream(String.format( "/sdcard/image/%d.jpg", System.currentTimeMillis())); outStream.write(baos.toByteArray()); outStream.close(); Toast.makeText(getApplicationContext(), "照片保存成功!", Toast.LENGTH_SHORT).show(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { } }
private PreviewCallback mPreviewCallback = new PreviewCallback() { @Override public void onPreviewFrame(byte[] data, Camera camera) { synchronized (MainService.this) { dataJPG = data; cameraJPG = camera; } } };
Android 关于获取摄像头帧数据解码,布布扣,bubuko.com
标签:android blog class code java c
原文地址:http://blog.csdn.net/u010794950/article/details/25694987