Android Exif使相机拍摄的图像为空白

Android Exif使相机拍摄的图像为空白,android,pdf,bitmap,camera,exif,Android,Pdf,Bitmap,Camera,Exif,在我的应用程序中,用户从相机或图库中捕获图像,然后将这些图像转换为PDF 问题是我试图编辑EXIF数据,因为三星设备会旋转图像 但现在PDF为空,但图像显示在ImageView中,但仍在旋转, 有什么建议吗 以下是将图像转换为PDF的代码,包括exif edditing private void PDFCreation(){ PdfDocument document=new PdfDocument(); PdfDocument.PageInfo pageInfo

在我的应用程序中,用户从相机或图库中捕获图像,然后将这些图像转换为PDF

问题是我试图编辑EXIF数据,因为三星设备会旋转图像

但现在PDF为空,但图像显示在ImageView中,但仍在旋转, 有什么建议吗

以下是将图像转换为PDF的代码,包括exif edditing

 private void PDFCreation(){
        PdfDocument document=new PdfDocument();
        PdfDocument.PageInfo pageInfo;
        PdfDocument.Page page;
        Canvas canvas;
        int i;
        for (i=0; i < list.size(); i++)  {
            pageInfo=new PdfDocument.PageInfo.Builder(992, 1432, 1).create();
            page=document.startPage(pageInfo);
            canvas=page.getCanvas();
            image=BitmapFactory.decodeFile(list.get(i));
            image=Bitmap.createScaledBitmap(image, 980, 1420, true);
            image.setDensity(DisplayMetrics.DENSITY_300);
            canvas.setDensity(DisplayMetrics.DENSITY_300);

            float rotation=0;
            try {
                ExifInterface exifInterface=new ExifInterface(selectedPhoto);
                int orientation=exifInterface.getAttributeInt(TAG_ORIENTATION, ORIENTATION_NORMAL);
                switch (orientation) {
                    case ExifInterface.ORIENTATION_ROTATE_90: {
                        rotation=-90f;
                        break;
                    }
                    case ExifInterface.ORIENTATION_ROTATE_180: {
                        rotation=-180f;
                        break;
                    }
                    case ExifInterface.ORIENTATION_ROTATE_270: {
                        rotation=90f;
                        break;
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

            Matrix matrix = new Matrix();
            matrix.postRotate(rotation);
            Bitmap.createBitmap(image, 0, 0,
                    image.getWidth(), image.getHeight(),
                    matrix, true);

            canvas.drawBitmap(image, 0, 0, null);
            document.finishPage(page);
        }
        @SuppressWarnings("deprecation") String directory_path=Environment.getExternalStorageDirectory().getPath() + "/mypdf/";
        File file=new File(directory_path);
        if (!file.exists()) {
            //noinspection ResultOfMethodCallIgnored
            file.mkdirs();
        }
        @SuppressLint("SimpleDateFormat") String timeStamp=(new SimpleDateFormat("yyyyMMdd_HHmmss")).format(new Date());
        String targetPdf=directory_path + timeStamp + ".pdf";
         filePath=new File(targetPdf);
        try {
            document.writeTo(new FileOutputStream(filePath));
        } catch (IOException e) {
            Log.e("main", "error " + e.toString());
            Toasty.error(this, "Error making PDF" + e.toString(), Toast.LENGTH_LONG).show();
        }
        document.close();
    }
private void PDFCreation(){
PdfDocument document=新PdfDocument();
PdfDocument.PageInfo PageInfo;
PDF文档。第页;
帆布;
int i;
对于(i=0;i
Bitmap.createBitmap(image,0,0,
您没有使用结果。结果应该是:
image=Bitmap.createBitmap(image,0,0,
@blackapps我现在明白您的意思了,那么如何实现旋转?