我正在尝试模仿一些生产代码来生成带有主题的 Tiff 以用于测试目的(Windows 中的 IE,右键单击,转到属性和详细信息选项卡有一个主题)。我们在主题字段中放置一些稍后需要参考的文本。我们使用的字段是 0x9c9f,据我所知是(Windows 使用的主题标签,在 UCS2 中编码)
这是我用来生成标签的代码
public static void TagExtender(Tiff tif)
{
TiffFieldInfo[] tiffFieldInfo =
{
new TiffFieldInfo(TIFFTAG_SUBJECT, 256, 256, TiffType.BYTE, FieldBit.Custom, true, false, "XPSubject"),
};
tif.MergeFieldInfo(tiffFieldInfo, tiffFieldInfo.Length);
//if (m_parentExtender != null)
// m_parentExtender(tif);
}
public static void GenerateTiff(string filename, int pages = 1, bool encrypt = false, string tag = null)
{
// Register the custom tag handler
if (m_parentExtender == null)
{
Tiff.TiffExtendProc extender = TagExtender;
m_parentExtender = Tiff.SetTagExtender(extender);
}
// Open the output image
using (Tiff output = Tiff.Open(filename, "w"))
{
//...other code to generate tiff
if (tag != null)
{
byte[] bytes = UnicodeStr2HexStr(tag);
output.SetField(TIFFTAG_SUBJECT, bytes.Length-1, bytes);
}
// Code to actually write the image ....
output.WriteDirectory();
}
output.Close();
}
基本上,标签(代码明智)似乎在 tiff 中,但 Windows 属性对话框从不显示它。需要什么特别的东西来实现这个吗?