0

我正在尝试修改/写入合理的属性项。一个合理的 Exif 属性是 Exposure Time:

在此处输入图像描述

来自 EXIF 标签的信息:0x829a、ExposureTime、rational64u、ExifIFD

然而,我遇到了障碍,不知道如何继续。我设法从图像中读取了曝光时间。不幸的是,我在理解如何更改和设置值时遇到了一些问题。

读取曝光时间的代码:

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

到目前为止我编写曝光时间的代码:

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

对我的“混乱”的任何帮助将不胜感激!

4

0 回答 0