相关疑难解决方法(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中的字节数组中读取EXIF数据

我想从相机输出的字节数组数据中读取EXIF数据.我知道我可以使用exifInterface从文件中读取EXIF数据.但这需要我将字节数组数据写入文件,读取EXIF数据,然后删除该文件.我想在不先写入文件的情况下阅读EXIF数据.

有没有人有任何想法?

android

15
推荐指数
2
解决办法
7535
查看次数

旋转的 Android CameraX 图像

我已经按照 Google CameraX代码实验室来实现自定义相机。相机预览很好,但是当我在旋转图像捕获图像后拍摄图像时。我正在以纵向模式拍摄图像,但保存的图像是横向的。这是配置相机的方法

private fun startCamera() {

    val cameraProviderFuture = ProcessCameraProvider.getInstance(this)

    cameraProviderFuture.addListener(Runnable {
        // Used to bind the lifecycle of cameras to the lifecycle owner
        val cameraProvider: ProcessCameraProvider = cameraProviderFuture.get()

        // Preview
        val preview = Preview.Builder()
            .setTargetRotation(this.windowManager.defaultDisplay.rotation)
            .build()
            .also {
                it.setSurfaceProvider(viewFinder.createSurfaceProvider())
            }

        imageCapture = ImageCapture.Builder()
            .setTargetRotation(this.windowManager.defaultDisplay.rotation)
            .build()

        val imageAnalyzer = ImageAnalysis.Builder()
            .build()
            .also {
                it.setAnalyzer(cameraExecutor, LuminosityAnalyzer { luma ->
                    Log.d(TAG, "Average luminosity: $luma")
                })
            }

        // Select back camera as a default
        val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA

        try { …
Run Code Online (Sandbox Code Playgroud)

android image-rotation android-orientation android-camera2 android-camerax

10
推荐指数
2
解决办法
3212
查看次数