Java Code Examples for android.util.Rational#getNumerator()

The following examples show how to use android.util.Rational#getNumerator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CameraXUtil.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@TargetApi(21)
public static @NonNull Size buildResolutionForRatio(int longDimension, @NonNull Rational ratio, boolean isPortrait) {
  int shortDimension = longDimension * ratio.getDenominator() / ratio.getNumerator();

  if (isPortrait) {
    return new Size(shortDimension, longDimension);
  } else {
    return new Size(longDimension, shortDimension);
  }
}
 
Example 2
Source File: OneCameraCharacteristicsImpl.java    From Camera2 with Apache License 2.0 5 votes vote down vote up
@Override
public float getExposureCompensationStep()
{
    if (!isExposureCompensationSupported())
    {
        return -1.0f;
    }
    Rational compensationStep = mCameraCharacteristics.get(
            CameraCharacteristics.CONTROL_AE_COMPENSATION_STEP);
    return (float) compensationStep.getNumerator() / compensationStep.getDenominator();
}
 
Example 3
Source File: AndroidCamera2Capabilities.java    From Camera2 with Apache License 2.0 4 votes vote down vote up
AndroidCamera2Capabilities(CameraCharacteristics p) {
    super(new Stringifier());

    StreamConfigurationMap s = p.get(SCALER_STREAM_CONFIGURATION_MAP);

    for (Range<Integer> fpsRange : p.get(CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES)) {
        mSupportedPreviewFpsRange.add(new int[] { fpsRange.getLower(), fpsRange.getUpper() });
    }

    // TODO: We only support TextureView preview rendering
    mSupportedPreviewSizes.addAll(Size.buildListFromAndroidSizes(Arrays.asList(
            s.getOutputSizes(SurfaceTexture.class))));
    for (int format : s.getOutputFormats()) {
        mSupportedPreviewFormats.add(format);
    }

    // TODO: We only support MediaRecorder video capture
    mSupportedVideoSizes.addAll(Size.buildListFromAndroidSizes(Arrays.asList(
            s.getOutputSizes(MediaRecorder.class))));

    // TODO: We only support JPEG image capture
    mSupportedPhotoSizes.addAll(Size.buildListFromAndroidSizes(Arrays.asList(
            s.getOutputSizes(ImageFormat.JPEG))));
    mSupportedPhotoFormats.addAll(mSupportedPreviewFormats);

    buildSceneModes(p);
    buildFlashModes(p);
    buildFocusModes(p);
    buildWhiteBalances(p);
    // TODO: Populate mSupportedFeatures

    // TODO: Populate mPreferredPreviewSizeForVideo

    Range<Integer> ecRange = p.get(CONTROL_AE_COMPENSATION_RANGE);
    mMinExposureCompensation = ecRange.getLower();
    mMaxExposureCompensation = ecRange.getUpper();

    Rational ecStep = p.get(CONTROL_AE_COMPENSATION_STEP);
    mExposureCompensationStep = (float) ecStep.getNumerator() / ecStep.getDenominator();

    mMaxNumOfFacesSupported = p.get(STATISTICS_INFO_MAX_FACE_COUNT);
    mMaxNumOfMeteringArea = p.get(CONTROL_MAX_REGIONS_AE);

    mMaxZoomRatio = p.get(SCALER_AVAILABLE_MAX_DIGITAL_ZOOM);
    // TODO: Populate mHorizontalViewAngle
    // TODO: Populate mVerticalViewAngle
    // TODO: Populate mZoomRatioList
    // TODO: Populate mMaxZoomIndex

    if (supports(FocusMode.AUTO)) {
        mMaxNumOfFocusAreas = p.get(CONTROL_MAX_REGIONS_AF);
        if (mMaxNumOfFocusAreas > 0) {
            mSupportedFeatures.add(Feature.FOCUS_AREA);
        }
    }
    if (mMaxNumOfMeteringArea > 0) {
        mSupportedFeatures.add(Feature.METERING_AREA);
    }

    if (mMaxZoomRatio > CameraCapabilities.ZOOM_RATIO_UNZOOMED) {
        mSupportedFeatures.add(Feature.ZOOM);
    }

    // TODO: Detect other features
}