首页 文章

7英寸平板电脑的纵向视图中的相机捕获图像未显示在Imageview中

提问于
浏览
0

我想在我的7英寸平板电脑3.2中通过图像中的相机显示图像捕获 . 当我捕获图像和控制返回到我的活动图像不显示在 Image View . 但同样的事情在智能手机上正常工作 .

我也尝试使用清单中的 android:configChanges="keyboardHidden|orientation" 进行该活动,但仍然存在问题 .

如果我通过将平板电脑保持在风景中捕获图像,它可以正常工作并显示图像 .

我将Camera intent称为如下

我在7英寸 Samsung tablet GT-P6200 版本 3.2 上运行我的应用程序 .

相机意图我打电话如下

Intent cameraIntent = new Intent();
cameraIntent.setAction(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, PICTURE_FROM_CAMERA);

请帮我解决这个问题

我的活动结果方法

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        if (requestCode == PICTURE_FROM_CAMERA) {
            Bitmap bitmap = (Bitmap) data.getExtras().get("data");
            photoView.setImageBitmap(bitmap);
        }
    }
}

2 回答

  • 0

    尝试将设备旋转到横向,因为MediaStore捕获仅适用于横向模式 .

  • 0

    这是某些标签中的常见问题,对于此问题,您可以尝试以下代码 . 这个对我有用 .

    try {
            File f = new File(SD_CARD_IMAGE_PATH);
            ExifInterface exif = new ExifInterface(f.getPath());
            int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
    
            int angle = 0;
    
            if (orientation == ExifInterface.ORIENTATION_ROTATE_90) {
                angle = 90;
            } 
            else if (orientation == ExifInterface.ORIENTATION_ROTATE_180) {
                angle = 180;
            } 
            else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) {
                angle = 270;
            }
    
            Matrix mat = new Matrix();
            mat.postRotate(angle);
    
            Bitmap bmp = BitmapFactory.decodeStream(new FileInputStream(f), null, null);
            Bitmap correctBmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), mat, true);                 
        }
        catch (IOException e) {
            Log.w("TAG", "-- Error in setting image");
        }   
        catch(OutOfMemoryError oom) {
            Log.w("TAG", "-- OOM Error in setting image");
        }
    

    但是我应该使用其他形式吗?

相关问题