tiff Windows成像组件C++

发布于 2025-01-22 00:05:38 字数 1401 浏览 2 评论 0 原文

我试图将libtiff替换为WIC(因为Libtiff无法通过黑鸭分析工具),

我已经使用了他们的示例

我能够创建一个TIFF。 我还需要更改压缩类型 因此,我将代码更改为

    if (SUCCEEDED(hr))
        {
            // This is how you customize the TIFF output.
            PROPBAG2 option = { 0 };
            option.pstrName = L"TiffCompressionMethod";
            VARIANT varValue;
            VariantInit(&varValue);
            varValue.vt = VT_UI1;
            varValue.bVal = WICTiffCompressionRLE;
            hr = pPropertybag->Write(1, &option, &varValue);
            if (SUCCEEDED(hr))
            {
                hr = piBitmapFrame->Initialize(pPropertybag);
            }
}

我的新图像具有分辨率单元2 我想将其设置为1

我找到了此 https://learn.microsoft.com/en-us/windows/windows/win32/wic/wic-photoprop-system-image-image-resolutionunit 但是我不明白如何使用WIC元数据API来改变这一点。

你能帮忙吗?

I am trying to replace libtiff into WIC (since libtiff is not able to pass Black Duck Analysis tool anymore)

I have used their example
https://learn.microsoft.com/en-us/windows/win32/wic/-wic-creating-encoder

And I was able to create a tiff.
I also needed to change the compression type
so I change the code into

    if (SUCCEEDED(hr))
        {
            // This is how you customize the TIFF output.
            PROPBAG2 option = { 0 };
            option.pstrName = L"TiffCompressionMethod";
            VARIANT varValue;
            VariantInit(&varValue);
            varValue.vt = VT_UI1;
            varValue.bVal = WICTiffCompressionRLE;
            hr = pPropertybag->Write(1, &option, &varValue);
            if (SUCCEEDED(hr))
            {
                hr = piBitmapFrame->Initialize(pPropertybag);
            }
}

My new image has Resolution Unit 2
and I would like to set it into 1
enter image description here

I found out this https://learn.microsoft.com/en-us/windows/win32/wic/-wic-photoprop-system-image-resolutionunit
but I do not understand how to use the WIC metadata API in order to change this.

Can you help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

原谅我要高飞 2025-01-29 00:05:38

WIC内置的TIFF编码器始终将 tifftag_resolutionunit 为2(英寸)。您可以使用WIC读取现有标签,但是不能为此特定的元数据编写其他值。

The WIC built-in TIFF encoder always writes the TIFFTAG_RESOLUTIONUNIT as 2 (inches). You can use WIC to read the existing tag, but you can't write a different value for this particular metadata item.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文