我构建了一个应用程序,对图片进行一些修改,更改它的 EXIF 缩略图以匹配新创建的图片并保存它。
它在 Win 7 下完美运行,但在 XP 下,EXIF 缩略图保持不变。这是更改缩略图的代码部分。
Dim MS As New MemoryStream()
Dim bmp_thumb = bmp.GetThumbnailImage(160, 120, Nothing, New IntPtr())
bmp_thumb.Save(MS, ImageFormat.Jpeg)
bmp_thumb.Dispose()
MS.Position = 0
Dim smallthumbbytes As Byte() = MS.ToArray()
Dim PropertyItems = bmp.PropertyItems
PropertyItems(0).Id = &H501B
PropertyItems(0).Type = 1
PropertyItems(0).Len = smallthumbbytes.Length
PropertyItems(0).Value = smallthumbbytes
bmp.SetPropertyItem(PropertyItems(0))
PropertyItems = bmp.PropertyItems
PropertyItems(0).Id = &H5023
PropertyItems(0).Type = CShort(3)
PropertyItems(0).Len = 2
PropertyItems(0).Value = New Byte() {6, 0}
bmp.SetPropertyItem(PropertyItems(0))
bmp.Save(filename)
我应该注意,图片的缩略图偏移在 XP 下也不会改变。
任何帮助表示赞赏!