[8132] | 1 | /*
|
---|
| 2 | * Copyright 2002-2015 Drew Noakes
|
---|
| 3 | *
|
---|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 5 | * you may not use this file except in compliance with the License.
|
---|
| 6 | * You may obtain a copy of the License at
|
---|
| 7 | *
|
---|
| 8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 9 | *
|
---|
| 10 | * Unless required by applicable law or agreed to in writing, software
|
---|
| 11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 13 | * See the License for the specific language governing permissions and
|
---|
| 14 | * limitations under the License.
|
---|
| 15 | *
|
---|
| 16 | * More information about this project is available at:
|
---|
| 17 | *
|
---|
| 18 | * https://drewnoakes.com/code/exif/
|
---|
| 19 | * https://github.com/drewnoakes/metadata-extractor
|
---|
| 20 | */
|
---|
| 21 | package com.drew.imaging;
|
---|
| 22 |
|
---|
| 23 | /**
|
---|
| 24 | * Contains helper methods that perform photographic conversions.
|
---|
| 25 | *
|
---|
| 26 | * @author Drew Noakes https://drewnoakes.com
|
---|
| 27 | */
|
---|
| 28 | public final class PhotographicConversions
|
---|
| 29 | {
|
---|
| 30 | public final static double ROOT_TWO = Math.sqrt(2);
|
---|
| 31 |
|
---|
| 32 | private PhotographicConversions() throws Exception
|
---|
| 33 | {
|
---|
| 34 | throw new Exception("Not intended for instantiation.");
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | /**
|
---|
| 38 | * Converts an aperture value to its corresponding F-stop number.
|
---|
| 39 | *
|
---|
| 40 | * @param aperture the aperture value to convert
|
---|
| 41 | * @return the F-stop number of the specified aperture
|
---|
| 42 | */
|
---|
| 43 | public static double apertureToFStop(double aperture)
|
---|
| 44 | {
|
---|
| 45 | return Math.pow(ROOT_TWO, aperture);
|
---|
| 46 |
|
---|
| 47 | // NOTE jhead uses a different calculation as far as i can tell... this confuses me...
|
---|
| 48 | // fStop = (float)Math.exp(aperture * Math.log(2) * 0.5));
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | /**
|
---|
| 52 | * Converts a shutter speed to an exposure time.
|
---|
| 53 | *
|
---|
| 54 | * @param shutterSpeed the shutter speed to convert
|
---|
| 55 | * @return the exposure time of the specified shutter speed
|
---|
| 56 | */
|
---|
| 57 | public static double shutterSpeedToExposureTime(double shutterSpeed)
|
---|
| 58 | {
|
---|
| 59 | return (float) (1 / Math.exp(shutterSpeed * Math.log(2)));
|
---|
| 60 | }
|
---|
| 61 | }
|
---|