c++wic

Tiff Windows Imaging Component c++


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?


Solution

  • 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.