GetValue() public method

Returns the value with the specified tag.
public GetValue ( ExifTag tag ) : ExifValue
tag ExifTag The tag of the exif value.
return ExifValue
    public void Test_ExifTag()
    {
      var exifProfile = new ExifProfile();

      exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)1);
      ExifValue value = exifProfile.GetValue(ExifTag.ResolutionUnit);
      Assert.AreEqual("None", value.ToString());

      exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)2);
      value = exifProfile.GetValue(ExifTag.ResolutionUnit);
      Assert.AreEqual("Inches", value.ToString());

      exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)3);
      value = exifProfile.GetValue(ExifTag.ResolutionUnit);
      Assert.AreEqual("Centimeter", value.ToString());

      exifProfile.SetValue(ExifTag.ResolutionUnit, (ushort)4);
      value = exifProfile.GetValue(ExifTag.ResolutionUnit);
      Assert.AreEqual("4", value.ToString());

      exifProfile.SetValue(ExifTag.ImageWidth, 123);
      value = exifProfile.GetValue(ExifTag.ImageWidth);
      Assert.AreEqual("123", value.ToString());
    }
示例#2
0
    public void Test_UnknownExifTag()
    {
      var exifProfile = new ExifProfile();
      exifProfile.SetValue(ExifTag.ImageWidth, 42);

      var bytes = exifProfile.ToByteArray();
      bytes[16] = 42;

      exifProfile = new ExifProfile(bytes);

      ExifTag unkownTag = (ExifTag)298;
      ExifValue value = exifProfile.GetValue(unkownTag);
      Assert.AreEqual(42, value.Value);
      Assert.AreEqual("42", value.ToString());

      bytes = exifProfile.ToByteArray();
      Assert.AreEqual(0, bytes.Length);
    }