android / android/camera-samples
CameraX providing Distorted bitmap when saving ImageProxy to bitmap.
- Dominant language
- Kotlin
- Stars
- 5.5k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
When trying to save the bitmap from ImageProxy it save the bitmap as distorted but only in case of FrontCamera. we have tested on multiple devices the issues only appears in OnePlus6T on camera2 it was working properly. If we remove the imageCapture from bind to lifecycle then it start returning proper bitmap in OnepPlus6T devices as well.
Changes done instead of **setAspectRatio** **setTargetResolution** is used where size is calculated using
` val metrics = windowManager.getCurrentWindowMetrics().bounds`
ImageAnalzyer now looks like this.
` imageAnalyzer = ImageAnalysis.Builder()
.setTargetResolution(maxSize)
.setTargetRotation(rotation)
.setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_RGBA_8888)
.setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
.build()
.also {
it.setAnalyzer(cameraExecutor, this)
}`
Bitmap is intialized
`bitmap = Bitmap.createBitmap(imageSize.width, imageSize.height, Bitmap.Config.ARGB_8888);`
Bitmap save is done in override analyze function
` bitmap!!.copyPixelsFromBuffer(image.image!!.planes[0].buffer);
val bos = ByteArrayOutputStream()
cameraBitmap!!.compress(Bitmap.CompressFormat.JPEG, 100, bos)
val bitmapdata = bos.toByteArray()`
Its happening on OnePlus 6T(A6010)
Android Version : 11
Oxygen OS Version : 11.1.2.2
Build Number : ONEPLUS A6010_41_21125
Contributor guide
Research direction
Start with the ImageAnalysis builder and the overridden analyze function described in the report, focusing on the target resolution, output image format, and ImageProxy buffer-to-bitmap path. Reproduce the front-camera case on the listed OnePlus 6T configuration with imageCapture bound, then compare the saved bitmap against the case where imageCapture is removed. Done means the front-camera bitmap is saved without distortion while imageCapture remains bound.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100