我试图模仿一些生产代码,以生成带有测试目的的主题( windows中的IE,右键单击,转到属性,details选项卡中有一个主题)。我们在主题字段中放置了一些我们需要稍后参考的文本。我们使用的字段是0x9c9f,据我所能找到的是(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属性对话框从未显示它。需要什么特别的东西来安排吗?
发布于 2015-07-29 07:02:29
您正在传递一个字节码,但是将passCount标志设置为false。
如果要传递计数,请在其正确位置使用这些行:
// Your FieldInfo
new TiffFieldInfo((TiffTag)40095, -1, -1, TiffType.BYTE, FieldBit.Custom, true, true, "XPSubject")
// Your Input
byte[] test = Encoding.Unicode.GetBytes("Test3");
tiff.SetField((TiffTag)40095, test.Length, test); https://stackoverflow.com/questions/31678781
复制相似问题