Balvinder Singh
Balvinder Singh

Reputation: 580

How to solve distorted image issue in android custom camera for galaxy S4

I am working on custom camera application for android. The problem is that the camera capture and showing preview good in other devices (example Samsung Galaxy S3) , but It shows distorted image on Galaxy s4, Can any one help me??

My code for Picturesize() method is as follows:

Camera.Size getBestPicturSize(int width, int height, Camera.Parameters parameters) {
        Camera.Size result=null;
        float dr = Float.MAX_VALUE;
        float ratio = (float)width/(float)height;

        for (Camera.Size size : parameters.getSupportedPreviewSizes()) {
            float r = (float)size.width/(float)size.height;
            if( Math.abs(r - ratio) < dr && size.width <= width && size.height <= height ) {
                dr = Math.abs(r - ratio);
                result = size;
            }
        }

        return result;
    }

Upvotes: 0

Views: 4298

Answers (1)

Ivo Pavlik
Ivo Pavlik

Reputation: 297

I had the same problem, if you mean that photos were taken with aspect ratio 4:3 and saved with aspect ratio 16:9 (they were outstretched). My problem was, that since I chose one of supported PictureSizes, I didn't do the same with the PreviewSizes. Supported PictureSizes for Samsung G S4 are only with aspect ratio 16:9, however default PreviewSize was set to 1440x1080, which is 4:3. When I set both sizes with the same aspect ratio, picture was taken with no distortion.

Hope it will help.

Upvotes: 1

Related Questions