1: public const string METADATA_TITLE = "Title";
2: public const string METADATA_SUBJECT = "Subject";
3: public const string METADATA_RATING = "Rating";
4: public const string METADATA_LOCATION = "Location";
5: public const string METADATA_KEYWORDS = "Keywords";
6: public const string METADATA_FORMAT = "Format";
7: public const string METADATA_DATETAKEN = "DateTaken";
8: public const string METADATA_COPYRIGHT = "Copyright";
9: public const string METADATA_COMMENT = "Comment";
10: public const string METADATA_CAMERAMODEL = "CameraModel";
11: public const string METADATA_CAMERAMANUFACTURER = "CameraManufacturer";
12: public const string METADATA_AUTHOR = "Author";
13: public const string METADATA_APPLICATIONNAME = "ApplicationName";
14: public static void GetImageMetadata(Dictionary<string, string> result, BitmapSource bs)
15: {
16:
17: if (bs != null)
18: {
19:
20: BitmapMetadata meta = bs.Metadata as BitmapMetadata;
21: if (meta.Title != null)
22: {
23: result.Add(METADATA_TITLE, meta.Title);
24: }
25: if (meta.Subject != null)
26: {
27: result.Add(METADATA_SUBJECT, meta.Subject);
28: }
29:
30: result.Add(METADATA_RATING, meta.Rating.ToString());
31: if (meta.Location != null)
32: {
33: result.Add(METADATA_LOCATION, meta.Location);
34: }
35: if (meta.Format != null)
36: {
37: result.Add(METADATA_FORMAT, meta.Format);
38: }
39: if (meta.DateTaken != null)
40: {
41: result.Add(METADATA_DATETAKEN, meta.DateTaken);
42: }
43: if (meta.Copyright != null)
44: {
45: result.Add(METADATA_COPYRIGHT, meta.Copyright);
46: }
47: if (meta.Comment != null)
48: {
49: result.Add(METADATA_COMMENT, meta.Comment);
50: }
51: if (meta.CameraModel != null)
52: {
53: result.Add(METADATA_CAMERAMODEL, meta.CameraModel);
54: }
55: if (meta.CameraManufacturer != null)
56: {
57: result.Add(METADATA_CAMERAMANUFACTURER, meta.CameraManufacturer);
58: }
59: StringBuilder keywords = new StringBuilder();
60: if (meta.Keywords != null)
61: {
62: foreach (string s in meta.Keywords)
63: {
64: keywords.Append(s).Append(" ");
65: }
66: result.Add(METADATA_KEYWORDS, keywords.ToString().Trim());
67: }
68: if (meta.ApplicationName != null)
69: {
70: result.Add(METADATA_APPLICATIONNAME, meta.ApplicationName);
71: }
72: if (meta.Author != null)
73: {
74: StringBuilder authors = new StringBuilder();
75: foreach (string s in meta.Author)
76: {
77: authors.Append(s).Append(",");
78: }
79: result.Add(METADATA_AUTHOR, authors.ToString().TrimEnd(new char[] { ',' }));
80: }
81:
82: }
83: }