Example usage for android.util Size getHeight

List of usage examples for android.util Size getHeight

Introduction

In this page you can find the example usage for android.util Size getHeight.

Prototype

public int getHeight() 

Source Link

Document

Get the height of the size (in pixels).

Usage

From source file:Main.java

@TargetApi(21)
public static Size chooseVideoSize(Size[] choices) {
    for (Size size : choices) {
        if (size.getWidth() == size.getHeight() * 4 / 3 && size.getWidth() <= 720) {
            return size;
        }/*from w  w w.j av  a2s. c o  m*/
    }
    return choices[choices.length - 1];
}

From source file:Main.java

public static boolean isWide(Size size) {
    double ratio = ((double) size.getWidth()) / ((double) size.getHeight());
    return ratio > 1.68 && ratio < 1.87;
}

From source file:Main.java

public static Size getMaxSize(Size[] sizes) {
    if (sizes == null || sizes.length == 0) {
        throw new IllegalArgumentException("sizes was empty");
    }//  w w  w .j a  v  a  2  s . com

    Size maxSize = sizes[0];
    for (int i = 1; i < sizes.length; i++) {
        if (sizes[i].getWidth() * sizes[i].getHeight() > maxSize.getWidth() * maxSize.getHeight()) {
            maxSize = sizes[i];
        }
    }

    return maxSize;
}

From source file:com.google.android.apps.watchme.StreamerActivity.java

private static Size chooseOptimalSize(Size[] choices, int width, int height) {
    List<Size> bigEnough = new ArrayList<Size>();
    for (Size option : choices) {
        if (option.getHeight() == option.getWidth() * height / width && option.getWidth() >= width
                && option.getHeight() >= height) {
            bigEnough.add(option);//w ww.  j a  va2  s. c o m
        }
    }
    if (bigEnough.size() > 0) {
        return Collections.min(bigEnough, new CompareSizeByArea());
    } else {
        return choices[0];
    }
}

From source file:com.tzutalin.dlibtest.CameraConnectionFragment.java

/**
 * Given {@code choices} of {@code Size}s supported by a camera, chooses the smallest one whose
 * width and height are at least as large as the respective requested values, and whose aspect
 * ratio matches with the specified value.
 *
 * @param choices     The list of sizes that the camera supports for the intended output class
 * @param width       The minimum desired width
 * @param height      The minimum desired height
 * @param aspectRatio The aspect ratio// w ww.  j  av a  2  s. c  o  m
 * @return The optimal {@code Size}, or an arbitrary one if none were big enough
 */
@SuppressLint("LongLogTag")
@DebugLog
private static Size chooseOptimalSize(final Size[] choices, final int width, final int height,
        final Size aspectRatio) {
    // Collect the supported resolutions that are at least as big as the preview Surface
    final List<Size> bigEnough = new ArrayList<Size>();
    for (final Size option : choices) {
        if (option.getHeight() >= MINIMUM_PREVIEW_SIZE && option.getWidth() >= MINIMUM_PREVIEW_SIZE) {
            Timber.tag(TAG).i("Adding size: " + option.getWidth() + "x" + option.getHeight());
            bigEnough.add(option);
        } else {
            Timber.tag(TAG).i("Not adding size: " + option.getWidth() + "x" + option.getHeight());
        }
    }

    // Pick the smallest of those, assuming we found any
    if (bigEnough.size() > 0) {
        final Size chosenSize = Collections.min(bigEnough, new CompareSizesByArea());
        Timber.tag(TAG).i("Chosen size: " + chosenSize.getWidth() + "x" + chosenSize.getHeight());
        return chosenSize;
    } else {
        Timber.tag(TAG).e("Couldn't find any suitable preview size");
        return choices[0];
    }
}

From source file:org.odk.collect.android.fragments.Camera2VideoFragment.java

/**
 * In this sample, we choose a video size with 3x4 aspect ratio. Also, we don't use sizes
 * larger than 1080p, since MediaRecorder cannot handle such a high-resolution video.
 *
 * @param choices The list of available sizes
 * @return The video size/*w w w  .ja v a 2s  . c  o m*/
 */
private static Size chooseVideoSize(Size[] choices) {
    for (Size size : choices) {
        if (size.getWidth() == size.getHeight() * 4 / 3 && size.getWidth() <= 1080) {
            return size;
        }
    }
    Timber.e("Couldn't find any suitable video size");
    return choices[choices.length - 1];
}

From source file:wisc.drivesense.vediorecorder.CameraFragment.java

/**
 * In this sample, we choose a video size with 3x4 aspect ratio. Also, we don't use sizes
 * larger than 1080p, since MediaRecorder cannot handle such a high-resolution video.
 *
 * @param choices The list of available sizes
 * @return The video size//ww w. ja v a 2  s  .co m
 */
private static Size chooseVideoSize(Size[] choices) {
    for (Size size : choices) {
        //Log.d(TAG, String.valueOf(size.getWidth()) + "," + String.valueOf(size.getHeight()));
        if (size.getWidth() == size.getHeight() * 4 / 3 && size.getWidth() <= 1080) {
            return size;
        }
    }
    Log.e(TAG, "Couldn't find any suitable video size");
    return choices[choices.length - 1];
}

From source file:com.android.rahul.myselfieapp.Fragment.CamVideoFragment.java

/**
 * In this sample, we choose a video size with 3x4 aspect ratio. Also, we don't use sizes
 * larger than 1080p, since MediaRecorder cannot handle such a high-resolution video.
 *
 * @param choices The list of available sizes
 * @return The video size//from   www .  ja  va2  s  . c  o  m
 */
private static Size chooseVideoSize(Size[] choices) {
    for (Size size : choices) {
        if (size.getWidth() == size.getHeight() * 4 / 3 && size.getWidth() <= 1080) {
            return size;
        }
    }
    Log.e(TAG, "Couldn't find any suitable video size");
    return choices[choices.length - 1];
}

From source file:com.mebene.ACHud.Camera2VideoFragment.java

/**
 * In this sample, we choose a video size with 3x4 aspect ratio. Also, we don't use sizes
 * larger than 1080p, since MediaRecorder cannot handle such a high-resolution video.
 *
 * @param choices The list of available sizes
 * @return The video size/*  ww  w . j  a  v  a2s .  c  o m*/
 */
private static Size chooseVideoSize(Size[] choices) {//16/9
    for (Size size : choices) {
        if (size.getWidth() == size.getHeight() * 4 / 3 && size.getWidth() <= 1080) {
            return size;
        }
    }
    Log.e(TAG, "Couldn't find any suitable video size");
    return choices[choices.length - 1];
}

From source file:com.caseystalnaker.android.popinvideodemo.fragments.Camera2VideoFragment.java

/**
 * In this sample, we choose a video size with 1X1 aspect ratio. Also, we don't use sizes
 * larger than 1080p, since MediaRecorder cannot handle such a high-resolution video.
 *
 * @param choices The list of available sizes
 * @return The video size/* w ww. ja v  a2  s.  c om*/
 */
private static Size chooseVideoSize(final Size[] choices) {
    for (Size size : choices) {
        if (size.getWidth() == size.getHeight() && size.getWidth() <= 1080) {
            return size;
        }
    }
    Log.w(LOGTAG, "Couldn't find any suitable video size");
    return choices[choices.length - 1];
}