Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

android - Samsung Galaxy S4 , Image gets corrupted while taking from camera

I'm using camera on my app. Camera is working perfect on all devices upto Samsung S3 even. Image is correct from all other devices.

While taking image from S4 , image gets corrupted and image gets saved with some lines in horizontal.

I tried changing resolution and everything but still issue is there .

Any help enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I've been pulling my hair out over this and I think I found the issue, at least with regards to my app - it's got something to do with the aspect ratio of the preview image versus the captured image.

In my case, my code was sniffing out the ideal preview size based on the aspect ratio of the screen. The S4 is a 1080p phone, so the preview image was 1920x1080, which is a 16:9 aspect ratio. But my code was hardcoded to capturing a 1600x1200 image, which is 4:3, because that's all I needed. But 1600x1200 is not one of the valid sizes the S4 supports.

Without setting the size, the S4 captured 4128x3096, which is the maximum size, and is 4:3, but the lines still appeared. Once I told the camera to capture a 16:9 photo, the lines went away. In your case, you might want to adjust the preview's aspect ratio.

Here's some code which can tell you the available sizes.

    List<Camera.Size> previewSizes = p.getSupportedPreviewSizes();

    int i = 1;

    for (Size previewSize : previewSizes) {
        Log.v("DebugCamera", "previewSize " + i++ + " width: " + previewSize.width + " height: " + previewSize.height);
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...