0
我正在處理這段代碼:內部方法調用元數據屬性全部填充; 但在用戶代碼中大多數都是空的。爲什麼會這樣?BitmapMetadata:一些屬性清除?
public static BitmapFrame GetImageIPTC(string imageFile)
{
BitmapFrame meta;
using (var fs = new FileStream(imageFile, FileMode.Open))
{
BitmapDecoder decoder = new JpegBitmapDecoder(fs, BitmapCreateOptions.None, BitmapCacheOption.None);
meta = decoder.Frames[0];
var a = ((BitmapMetadata) meta.Metadata).CameraModel;
}
return meta;
}
在方法中的元數據屬性是:
ApplicationName "Adobe Photoshop CS5 Windows" string
- Author Count = 1 System.Collections.ObjectModel.ReadOnlyCollection<string>
[0] "Michele Virgilio" string
CameraManufacturer "Canon" string
CameraModel "Canon EOS 450D" string
Comment null string
Copyright "© Michele Virgilio" string
DateTaken "16/04/2011 10:30:48" string
Format "jpg" string
IsFixedSize false bool
IsReadOnly false bool
+ Keywords Count = 96 System.Collections.ObjectModel.ReadOnlyCollection<string>
Location "/" string
Rating 0 int
Subject "Subject description" string
Title "Title description" string
用戶代碼:
var actual = ImageInfo.GetImageIPTC(filespec);
var bitmapMetadata = (BitmapMetadata)actual.Metadata;
var a = bitmapMetadata.CameraModel;
正如你可以看到所有的屬性都存在,但主題:
ApplicationName "Adobe Photoshop CS5 Windows" string
- Author Count = 1 System.Collections.ObjectModel.ReadOnlyCollection<string>
[0] "Michele Virgilio" string
CameraManufacturer "Canon" string
CameraModel "Canon EOS 450D" string
Comment null string
Copyright "© Michele Virgilio" string
DateTaken "16/04/2011 10:30:48" string
Format "jpg" string
IsFixedSize false bool
IsReadOnly true bool
+ Keywords Count = 96 System.Collections.ObjectModel.ReadOnlyCollection<string>
Location "/" string
Rating 0 int
Subject null string
Title "Title description" string
是的,但爲什麼只有一些屬性清除了BitmapMetadata?還有一個可以從方法調用中獲取元數據的工作區? –
只有一些meta被清除?這聽起來很奇怪。創建元數據的副本並返回。 – Fischermaen
已經嘗試使用BitmapMetadata的內置克隆方法,但沒有運氣 –