Android Camera Size Get getSizeRATIO(List sizes, int w, int h)

Here you can find the source of getSizeRATIO(List sizes, int w, int h)

Description

get Size RATIO

Declaration

private static Size getSizeRATIO(List<Size> sizes, int w, int h) 

Method Source Code

//package com.java2s;
import java.util.List;

import android.hardware.Camera.Size;

public class Main {
    private static Size getSizeRATIO(List<Size> sizes, int w, int h) {
        Size re = null;/*from w w  w  .  j av a2s .c  o  m*/
        double wantRatio = (double) w / (double) h;
        double minGap = wantRatio;
        for (Size size : sizes) {
            if (getRatioGap(size, wantRatio) < minGap) {
                minGap = getRatioGap(size, wantRatio);
                re = size;
            }
        }
        return re;
    }

    private static double getRatioGap(Size size, double wantRatio) {
        double sizeRatio = (double) size.height / (double) size.width;
        return Math.abs(sizeRatio - wantRatio);
    }
}

Related

  1. getLargestPictureSize(CameraHost host, Camera.Parameters parameters)
  2. getOptimalPreviewSize(int displayOrientation, int width, int height, Camera.Parameters parameters)
  3. getSmallestPictureSize(Camera.Parameters parameters)
  4. getPreviewSize(Camera.Parameters cp)
  5. getSizeLB(List sizes, int w, int h)
  6. getSizeSIZE(List sizes, int w, int h)
  7. getSizeWIDTH(List sizes, int w, int h)
  8. getOptimalPreviewSize( List sizes, int w, int h)
  9. getOptimalPreviewSize(List sizes, int w, int h)