如何把刚刚拍的照片放在  ImageView  控件中,照片是程序通过调用摄像头当现得到的,不能用imageView.setImageDrawable(getResourse().getDrawabel(R.id.xx))   我想把照片在保持进sd卡中前吧照片放在ImageView  控件中,如何做到???急!!!

解决方案 »

  1.   

    加:这是 android 开发
      

  2.   

    不行
    public void onPictureTaken(byte[] data, Camera camera) 
    {
    try {
    Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
    File file = new File(Environment.getExternalStorageDirectory(),imagename+".jpg");

    FileOutputStream outStream = new FileOutputStream(file);
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream);

    outStream.flush();
    outStream.close();
    //到这里就出差错【为何】

    } catch (Exception e) {
    Log.e(TAG, e.toString());
    }
      

  3.   

    public void onPictureTaken(byte[] data, Camera camera) 
    {
    try {
    Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
    File file = new File(Environment.getExternalStorageDirectory(),imagename+".jpg");

    FileOutputStream outStream = new FileOutputStream(file);
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream);

    outStream.flush();
    outStream.close();
    //到这里就出差错【为何】
    frontimageview.setImageBitmap(bitmap);

    } catch (Exception e) {
    Log.e(TAG, e.toString());
    }
    }
      

  4.   

    public void onPictureTaken(byte[] data, Camera camera) {
    Bitmap bm = BitmapFactory.decodeByteArray(data, 0, data.length);
    //创建新文件
    Calendar c = Calendar.getInstance();
    //获取当前时间秒,以时间命名
    strCaptureFilePath = "/sdcard/DCIM/Camera/" + c.get(Calendar.SECOND) + ".jpg";
    File myCaptureFile = new File(strCaptureFilePath);
    try {
    BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
    //采用压缩文件的方法
    bm.compress(Bitmap.CompressFormat.JPEG, 80, bos);
    //调用flush()方法,更新BufferStream
    bos.flush();
    //结束OutputStream
    bos.close();
    //将拍照下来并存储完毕的图片文件,显示出来
    mImageView01.setImageBitmap(bm); //显示完图片文件,立即重置相机,并关闭预览
    resetCamera();
    //再重启相机继续预览
    initCamera();
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }这是我当时做的一个,就是这么处理的,不早点lz报的什么错?
      

  5.   

    logCat里的输出,在DDMS或debug界面可以看到