using System;
using System.Collections;
using System.Text;
using com.drew.metadata;
using com.drew.lang;
///
/// This class was first written by Drew Noakes in Java.
///
/// This is public domain software - that is, you can do whatever you want
/// with it, and include it software that is licensed under the GNU or the
/// BSD license, or whatever other licence you choose, including proprietary
/// closed source licenses. I do ask that you leave this header in tact.
///
/// If you make modifications to this code that you think would benefit the
/// wider community, please send me a copy and I'll post it on my site.
///
/// If you make use of this code, Drew Noakes will appreciate hearing
/// about it: drew@drewnoakes.com
///
/// Latest Java version of this software kept at
/// http://drewnoakes.com/
///
/// The C# class was made by Ferret Renaud:
/// renaud91@free.fr
/// If you find a bug in the C# code, feel free to mail me.
///
namespace com.drew.metadata.exif
{
///
/// Tag descriptor for almost every images
///
public class ExifInteropDescriptor : TagDescriptor
{
///
/// Constructor of the object
///
/// a directory
public ExifInteropDescriptor(Directory directory) : base(directory)
{
}
///
/// Returns a descriptive value of the the specified tag for this image.
/// Where possible, known values will be substituted here in place of the raw tokens actually
/// kept in the Exif segment.
/// If no substitution is available, the value provided by GetString(int) will be returned.
/// This and GetString(int) are the only 'get' methods that won't throw an exception.
///
/// the tag to find a description for
/// a description of the image's value for the specified tag, or null if the tag hasn't been defined.
public override string GetDescription(int tagType)
{
switch(tagType)
{
case ExifInteropDirectory.TAG_INTEROP_INDEX:
return GetInteropIndexDescription();
case ExifInteropDirectory.TAG_INTEROP_VERSION:
return GetInteropVersionDescription();
default:
return _directory.GetString(tagType);
}
}
///
/// Returns the Interop Version Description.
///
/// the Interop Version Description.
private string GetInteropVersionDescription()
{
if (!_directory.ContainsTag(ExifInteropDirectory.TAG_INTEROP_VERSION))
return null;
int[] ints =
_directory.GetIntArray(ExifInteropDirectory.TAG_INTEROP_VERSION);
return ExifDescriptor.ConvertBytesToVersionString(ints);
}
///
/// Returns the Interop index Description.
///
/// the Interop index Description.
private string GetInteropIndexDescription()
{
if (!_directory.ContainsTag(ExifInteropDirectory.TAG_INTEROP_INDEX))
return null;
string interopIndex =
_directory.GetString(ExifInteropDirectory.TAG_INTEROP_INDEX).Trim();
if ("R98".Equals(interopIndex.ToUpper()))
{
return BUNDLE["RECOMMENDED_EXIF_INTEROPERABILITY"];
}
else
{
return BUNDLE["UNKNOWN", interopIndex.ToString()];
}
}
}
}