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

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

Description

get Size LB

Declaration

private static Size getSizeLB(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 getSizeLB(List<Size> sizes, int w, int h) {
        Size re = null;/*from  w ww . j a  va  2  s.c om*/
        int wantSize = w * h;
        int minGap = wantSize;
        for (Size size : sizes) {
            if (getSizeGapValue(size, wantSize) > 0
                    && getSizeGapValue(size, wantSize) < minGap) {
                re = size;
                minGap = getSizeGap(size, wantSize);
            }
        }
        return re;
    }

    private static int getSizeGapValue(Size size, int wantSize) {
        return size.width * size.height - wantSize;
    }

    private static int getSizeGap(Size size, int wantSize) {
        return Math.abs(size.width * size.height - wantSize);
    }
}

Related

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