I am trying to modify / write to property items that are rational. One Exif property that is rational is the Exposure Time:
Information from EXIF Tags: 0x829a, ExposureTime, rational64u, ExifIFD
I have however run into a roadblock and don't know how to continue. I have managed to read the Exposure time from an image. Unfortunatly I am having some issues understanding how I would change the value and set it.
Code for reading the Exposure Time:
Public Class Class1
Private Image As Bitmap ' I have code to get the filepath of the image, which I didn't include here.
Public Function RationalRead()
Dim item = Image.GetPropertyItem(&H829A)
Dim Num = BitConverter.ToUInt32(item.Value, 0)
Dim Denom = BitConverter.ToUInt32(item.Value, 4)
Dim expostime = Num & "/" & Denom
Return expostime
End Function
End Class
Code I have so far to write the Exposure Time:
Public Class Class1
Private Image As Bitmap ' I have code to get the filepath of the image, which I didn't include here.
Public Sub RationalWrite()
Dim item = Image.PropertyItems(&H829A)
Dim Num = BitConverter.ToUInt32(item.Value, 0) ' I would need to be able to change the value inside the first bit here to something different.
Dim Denom = BitConverter.ToUInt32(item.Value, 4) ' I would need to be able to change the value inside the fourth bit here to something different.
Dim ImageProperty As Imaging.PropertyItem = Image.PropertyItems(0)
ImageProperty.Id = &HA404 ' The Metatag ID to modify (in our case ExposureTime)
ImageProperty.Value = ' Here I would need to combine Num and Denom so that ImageProperty.Value can read the bits.
ImageProperty.Type = 5 ' The 5 stands for UnsignedRational
ImageProperty.Len = 8 ' I don't know if this should be 7 or 8.
Image.SetPropertyItem(ImageProperty)
End Sub
End Class
Any help with my "chaos" will be appreciated!