[4231] | 1 | /*
|
---|
| 2 | * This is public domain software - that is, you can do whatever you want
|
---|
| 3 | * with it, and include it software that is licensed under the GNU or the
|
---|
| 4 | * BSD license, or whatever other licence you choose, including proprietary
|
---|
| 5 | * closed source licenses. I do ask that you leave this header in tact.
|
---|
| 6 | *
|
---|
| 7 | * If you make modifications to this code that you think would benefit the
|
---|
| 8 | * wider community, please send me a copy and I'll post it on my site.
|
---|
| 9 | *
|
---|
| 10 | * If you make use of this code, I'd appreciate hearing about it.
|
---|
| 11 | * drew@drewnoakes.com
|
---|
| 12 | * Latest version of this software kept at
|
---|
| 13 | * http://drewnoakes.com/
|
---|
| 14 | */
|
---|
| 15 | package com.drew.imaging;
|
---|
| 16 |
|
---|
| 17 | /**
|
---|
| 18 | * Contains helper methods that perform photographic conversions.
|
---|
| 19 | */
|
---|
| 20 | public class PhotographicConversions
|
---|
| 21 | {
|
---|
| 22 | public final static double ROOT_TWO = Math.sqrt(2);
|
---|
| 23 |
|
---|
| 24 | private PhotographicConversions()
|
---|
| 25 | {}
|
---|
| 26 |
|
---|
| 27 | /**
|
---|
| 28 | * Converts an aperture value to its corresponding F-stop number.
|
---|
| 29 | * @param aperture the aperture value to convert
|
---|
| 30 | * @return the F-stop number of the specified aperture
|
---|
| 31 | */
|
---|
| 32 | public static double apertureToFStop(double aperture)
|
---|
| 33 | {
|
---|
| 34 | double fStop = Math.pow(ROOT_TWO, aperture);
|
---|
| 35 | return fStop;
|
---|
| 36 |
|
---|
| 37 | // Puzzle?!
|
---|
| 38 | // jhead uses a different calculation as far as i can tell... this confuses me...
|
---|
| 39 | // fStop = (float)Math.exp(aperture * Math.log(2) * 0.5));
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | /**
|
---|
| 43 | * Converts a shutter speed to an exposure time.
|
---|
| 44 | * @param shutterSpeed the shutter speed to convert
|
---|
| 45 | * @return the exposure time of the specified shutter speed
|
---|
| 46 | */
|
---|
| 47 | public static double shutterSpeedToExposureTime(double shutterSpeed)
|
---|
| 48 | {
|
---|
| 49 | return (float)(1 / Math.exp(shutterSpeed * Math.log(2)));
|
---|
| 50 | }
|
---|
| 51 | }
|
---|