首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LibTiff.net没有设置主题标记

LibTiff.net没有设置主题标记
EN

Stack Overflow用户
提问于 2015-07-28 14:08:32
回答 1查看 113关注 0票数 1

我试图模仿一些生产代码,以生成带有测试目的的主题( windows中的IE,右键单击,转到属性,details选项卡中有一个主题)。我们在主题字段中放置了一些我们需要稍后参考的文本。我们使用的字段是0x9c9f,据我所能找到的是(UCS2使用的主题标记)

下面是我用来生成标记的代码

代码语言:javascript
复制
   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属性对话框从未显示它。需要什么特别的东西来安排吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-29 07:02:29

您正在传递一个字节码,但是将passCount标志设置为false。

如果要传递计数,请在其正确位置使用这些行:

代码语言:javascript
复制
// 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);   
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31678781

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档