List of utility methods to do Camera Size Get
Size | getBestAspectPreviewSize(int displayOrientation, int width, int height, Camera.Parameters parameters, double closeEnough) get Best Aspect Preview Size double targetRatio = (double) width / height; Size optimalSize = null; double minDiff = Double.MAX_VALUE; if (displayOrientation == 90 || displayOrientation == 270) { targetRatio = (double) height / width; List<Size> sizes = parameters.getSupportedPreviewSizes(); Collections.sort(sizes, ... |
Size | getLargestPictureSize(CameraHost host, Camera.Parameters parameters) get Largest Picture Size Size result = null; for (Size size : parameters.getSupportedPictureSizes()) { if (size.height <= host.getDeviceProfile() .getMaxPictureHeight() && size.height >= host.getDeviceProfile() .getMinPictureHeight()) { if (result == null) { result = size; ... |
Size | getOptimalPreviewSize(int displayOrientation, int width, int height, Camera.Parameters parameters) get Optimal Preview Size double targetRatio = (double) width / height; List<Size> sizes = parameters.getSupportedPreviewSizes(); Size optimalSize = null; double minDiff = Double.MAX_VALUE; int targetHeight = height; if (displayOrientation == 90 || displayOrientation == 270) { targetRatio = (double) height / width; for (Size size : sizes) { double ratio = (double) size.width / size.height; if (Math.abs(ratio - targetRatio) <= ASPECT_TOLERANCE) { if (Math.abs(size.height - targetHeight) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - targetHeight); if (optimalSize == null) { minDiff = Double.MAX_VALUE; for (Size size : sizes) { if (Math.abs(size.height - targetHeight) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - targetHeight); return (optimalSize); |
Size | getSmallestPictureSize(Camera.Parameters parameters) get Smallest Picture Size Size result = null; for (Size size : parameters.getSupportedPictureSizes()) { if (result == null) { result = size; } else { int resultArea = result.width * result.height; int newArea = size.width * size.height; if (newArea < resultArea) { ... |
Camera.Size | getPreviewSize(Camera.Parameters cp) get Preview Size Camera.Size size = cp.getPreferredPreviewSizeForVideo(); if (size == null) size = cp.getSupportedPreviewSizes().get(0); return size; |
Size | getSizeLB(List get Size LB Size re = null; 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); ... |
Size | getSizeRATIO(List get Size RATIO Size re = null; 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; |
Size | getSizeSIZE(List get Size SIZE Size re = null; int wantSize = w * h; int minGap = wantSize; for (Size size : sizes) { if (getSizeGap(size, wantSize) < minGap) { re = size; minGap = getSizeGap(size, wantSize); return re; |
Size | getSizeWIDTH(List get Size WIDTH int wantWidth = w; Size re = null; int minGap = w; for (Size size : sizes) { if (getWidthGap(size, wantWidth) < minGap) { minGap = getWidthGap(size, wantWidth); re = size; return re; |
Camera.Size | getOptimalPreviewSize( List Iterate over supported camera preview sizes to see which one best fits the dimensions of the given view while maintaining the aspect ratio. final double ASPECT_TOLERANCE = 0.1; double targetRatio = (double) w / h; if (sizes == null) return null; Camera.Size optimalSize = null; double minDiff = Double.MAX_VALUE; int targetHeight = h; for (Camera.Size size : sizes) { ... |