如何从相机拍摄多个图像并保存到阵列然后转换64Base

时间:2017-02-10 06:38:32

标签: android arrays

这是我的职能。

我必须动态捕获多个图像并在运行时显示在图像视图中并保存到数组然后将数组编码到Base64然后发布到json ...

    private void setPic() {
    // Get the dimensions of the View
    int targetW = account_image.getWidth();
    int targetH = account_image.getHeight();

    // Get the dimensions of the bitmap
    BitmapFactory.Options bmOptions = new BitmapFactory.Options();
    bmOptions.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(String.valueOf(mCurrentPhotoPath), bmOptions);
    int photoW = bmOptions.outWidth;
    int photoH = bmOptions.outHeight;

    // Determine how much to scale down the image
    int scaleFactor = Math.min(photoW / targetW, photoH / targetH);

    // Decode the image file into a Bitmap sized to fill the View
    bmOptions.inJustDecodeBounds = false;
    bmOptions.inSampleSize = scaleFactor;
    bmOptions.inPurgeable = true;

    Bitmap bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);

    account_image.setImageBitmap(bitmap);
}

private File createImageFile() throws IOException {
    // Create an image file name
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    String imageFileName = "JPEG_" + timeStamp + "_";
    File storageDir = Environment.getExternalStoragePublicDirectory(
            Environment.DIRECTORY_PICTURES);

    File image = File.createTempFile(
            imageFileName,  /* prefix */
            ".jpg",         /* suffix */
            storageDir      /* directory */
    );

    // Save a file: path for use with ACTION_VIEW intents
    mCurrentPhotoPath = image.getAbsolutePath();



    Log.e("Getpath", "Cool" + mCurrentPhotoPath);
    return image;
}

请指导我如何完成工作

0 个答案:

没有答案