添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
public void onPreviewFrame(byte[] data, Camera camera) Size size = camera.getParameters().getPreviewSize(); try { YuvImage image = new YuvImage(data, ImageFormat.NV21,size.width, size.height, null); if (image != null) { // 保存图片 /// File file = new File(Environment.getExternalStorageDirectory().getPath() + File.separator+"picture.jpg"); FileOutputStream stream = new FileOutputStream(file); if (image.compressToJpeg(new Rect(0, 0, size.width, size.height), 80, stream)) { stream.flush(); stream.close(); / 转为Bitmap / ByteArrayOutputStream stream = new ByteArrayOutputStream(); image.compressToJpeg(new Rect(0, 0, size.width, size.height), 80, stream); Bitmap bmp=BitmapFactory.decodeByteArray(stream.toByteArray(), 0, stream.size()); stream.close(); } catch (Exception ex) { e.printStackTrace();
InputStream java 设置编码 java inputstream available

API 对 available() 方法说明:/** * 返回此输入流下一个方法调用可以不受阻塞地从此输入流读取(或跳过)的估计字节数。 * 下一个调用可能是同个线程,也可能是另一个线程。 * 一次读取或跳过此估计数个字节不会受阻塞,但读取或跳过的字节数可能小于该数。 public int available() throws IOException要一次读取多个字节时,经常用到 Input