相关疑难解决方法(0)

为什么在Android上的某些设备上使用相机意图捕获的图像会被旋转?

我正在捕捉图像并将其设置为图像视图.

public void captureImage() {

    Intent intentCamera = new Intent("android.media.action.IMAGE_CAPTURE");
    File filePhoto = new File(Environment.getExternalStorageDirectory(), "Pic.jpg");
    imageUri = Uri.fromFile(filePhoto);
    MyApplicationGlobal.imageUri = imageUri.getPath();
    intentCamera.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
    startActivityForResult(intentCamera, TAKE_PICTURE);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intentFromCamera) {
    super.onActivityResult(requestCode, resultCode, intentFromCamera);

    if (resultCode == RESULT_OK && requestCode == TAKE_PICTURE) {

        if (intentFromCamera != null) {
            Bundle extras = intentFromCamera.getExtras();
            if (extras.containsKey("data")) {
                bitmap = (Bitmap) extras.get("data");
            }
            else {
                bitmap = getBitmapFromUri();
            }
        }
        else {
            bitmap = getBitmapFromUri();
        }
        // …
Run Code Online (Sandbox Code Playgroud)

camera android image rotation android-camera-intent

344
推荐指数
11
解决办法
19万
查看次数

Android:以一定角度在imageview中旋转图像

我使用以下代码在ImageView中旋转图像一个角度.有没有更简单,更简单的方法可用.

ImageView iv = (ImageView)findViewById(imageviewid);
TextView tv = (TextView)findViewById(txtViewsid);
Matrix mat = new Matrix();
Bitmap bMap = BitmapFactory.decodeResource(getResources(),imageid);
mat.postRotate(Integer.parseInt(degree));===>angle to be rotated
Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0,bMap.getWidth(),bMap.getHeight(), mat, true);
iv.setImageBitmap(bMapRotate);
Run Code Online (Sandbox Code Playgroud)

android bitmap rotation imageview

147
推荐指数
9
解决办法
28万
查看次数

Android:从图库加载的位图在ImageView中旋转

当我将媒体库中的图像加载到位图时,一切都运行正常,除了在垂直拿着手机时用相机拍摄的图片被旋转,以便我总是得到水平图片,即使它在画廊.为什么这样,我怎么能正确加载它?

android bitmap rotation gallery

132
推荐指数
8
解决办法
11万
查看次数