2017年6月2日金曜日

android Bitmap to File

android Bitmap to File


    case REQUEST_IMAGE_CAPTURE:
        File f = getFilesDir();
        Bitmap bit = data.getExtras().getParcelable("data");
        ImageView imageView = (ImageView) findViewById(R.id.bit);
        imageView.setImageBitmap(bit);

        try {
            FileOutputStream fileOutputStream = new FileOutputStream(f.getPath() + "/xxx.jpg");
            bit.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
            fileOutputStream.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        break;

0 件のコメント: