X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fjpeg%2FExifGateway.java;fp=tim%2Fprune%2Fjpeg%2FExifGateway.java;h=9fefadf33c78003248e12e119481346c667166d6;hp=c60afb299822c623f7a4abe77a78e485e50bdc00;hb=f35b6d628f68e3b5ef19965ad8988d0dd1eb8efa;hpb=3745d70b1427bb8ac1a085e47cbdc566936784e1 diff --git a/tim/prune/jpeg/ExifGateway.java b/tim/prune/jpeg/ExifGateway.java index c60afb2..9fefadf 100644 --- a/tim/prune/jpeg/ExifGateway.java +++ b/tim/prune/jpeg/ExifGateway.java @@ -1,9 +1,7 @@ package tim.prune.jpeg; import java.io.File; - import javax.swing.JOptionPane; - import tim.prune.I18nManager; /** @@ -12,10 +10,8 @@ import tim.prune.I18nManager; * to the external libmetadata-extractor-java library * instead of the included modified routines. * - * To use the internal routines, set the USE_INTERNAL_LIBRARY flag to true - * and include the internal classes in the compiled jar. - * To use the external library, set the USE_INTERNAL_LIBRARY flag to false - * and do not export the internal classes. + * Switching between internal and external libraries is + * handled by the ExifLibrarySwitch */ public abstract class ExifGateway { @@ -71,4 +67,25 @@ public abstract class ExifGateway if (_exifLibrary == null || !_exifLibrary.looksOK()) {key = key + ".failed";} return key; } + + + + /** + * @param inNumerator numerator from Rational + * @param inDenominator denominator from Rational + * @return the value of the specified number as a positive double. + * Prevents interpretation of 32 bit numbers as negative, and forces a positive answer + */ + public static final double convertToPositiveValue(int inNumerator, int inDenominator) + { + if (inDenominator == 0) return 0.0; + double numeratorDbl = inNumerator; + double denomDbl = inDenominator; + if (inNumerator >= 0) + return numeratorDbl / denomDbl; + final double correction = Math.pow(2.0, 32); + numeratorDbl += correction; + if (inDenominator < 0) denomDbl += correction; + return numeratorDbl / denomDbl; + } }