0

按下 capture 后Button,图像应该保存在 sdcard 中,它正在拍摄快照但不保存图像,那么我怎样才能将捕获按钮放在我想要的任何地方?我有一个覆盖层,Imageview我需要将按钮放在覆盖层上。

4

3 回答 3

1

int 图片回调,这样使用

jpegCallback = new PictureCallback() {
        public void onPictureTaken(byte[] data, Camera camera) {
            camera.startPreview();
            FileOutputStream outStream = null;
            try {
                outStream = new FileOutputStream(
                        "/mnt/sdcard/myphoto.jpg");
                outStream.write(data);
                outStream.close();
                Log.d("Log", "onPictureTaken - wrote bytes: " + data.length);
            } catch (FileNotFoundException e) {
                e.printStackTrace();

            } catch (IOException e) {
                e.printStackTrace();
            } finally {

            }
            Log.d("Log", "onPictureTaken - jpeg");
        }
    };
于 2013-05-21T08:02:05.960 回答
1

使用这个将图像存储在 sd 卡中

     public void save(Bitmap image)
                     {
            File sdcard = Environment.getExternalStorageDirectory();
            File f = new File (sdcard, imagename);
            FileOutputStream out=null;
            try {
                out = new FileOutputStream(f);
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            image.compress(Bitmap.CompressFormat.PNG, 90, out);
            try {
                out.flush();
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
}
于 2013-05-21T08:04:53.413 回答
0
stream=new ByteArrayOutputStream();
temBitmap=Bitmap.createBitmap(bmp);
temBitmap.compress(Bitmap.CompressFormat.JPEG,100, stream);
 path+=String.format(
                getString(R.string._sdcard_d_jpg),
                System.currentTimeMillis());
  outStream = new FileOutputStream(path+extension); // <9>
  outStream.write(stream.toByteArray());
  outStream.close();   

以这种方式更改上面的代码段:

    path+=String.format(
            getString(R.string._sdcard_d_jpg),
            System.currentTimeMillis());
    outStream = new FileOutputStream(path+extension); // <9>
    temBitmap=Bitmap.createBitmap(bmp);
    temBitmap.compress(Bitmap.CompressFormat.JPEG,100, outStream);
    outStream.close();     
     temBitmap.recycle()
于 2013-05-21T08:04:59.993 回答