Jump to content

GeoTIFF Issues (v4.2.10 Store)


Recommended Posts

GitHub Repo for Sample Data:  

https://github.com/Saijin-Naib/WIC-GeoTIFF-Testfiles

 

Image Set: Standard_GeoTiff_LZW

 

Issues:

16bit Image (Signed / Unsigned) display in monochrome unexpectedly

image.png.6cdd8f4deab68cdcc924ad0f0125bb7f.png

NAIP_16s (PDN)

 

image.png.2e21af5f4418e85c47dfa68f71dab313.png

NAIP_16s (QGIS)

 

image.png.6a3cb78968adac5ee1ad36bd14692cb2.png

NAIP_16u (PDN)

 

image.png.7fb4a054a595bc06ac48d038a471230e.png

NAIP_16u (QGIS)

 

Issues:

32bit and 64bit images fail to Import/Export

NAIP_32f

Application version: paint.net 4.2.10



PaintDotNet.Imaging.BadImageException (0x88982F60): D:\src\pdn\src\SystemLayer.Native\Imaging\WICBitmapSource.cpp (170) : hr = m_pBitmapSource->CopyPixels( pSrcRectWic, static_cast<UINT>(stride), bufferSize, reinterpret_cast<BYTE*>(buffer.ToPointer()));

   at PaintDotNet.Interop.InteropErrorInfo.ThrowIfError() in D:\src\pdn\src\Base\Interop\InteropErrorInfo.cs:line 98

   at PaintDotNet.SystemLayer.Native.x64.NativeUtilities.ThrowOnErrorImpl(Int32 hr, SByte* szHr, IUnknown* pFxErrorInfo) in D:\src\pdn\src\SystemLayer.Native\NativeUtilities.cpp:line 70

   at PaintDotNet.SystemLayer.Native.x64.Imaging.WICBitmapSource.CopyPixels(Nullable`1 srcRect, Int32 stride, UInt32 bufferSize, IntPtr buffer) in D:\src\pdn\src\SystemLayer.Native\Imaging\WICBitmapSource.cpp:line 156

   at PaintDotNet.Imaging.Proxies.BitmapSourceProxy.CopyPixels(Nullable`1 srcRect, Int32 bufferStride, UInt32 bufferSize, IntPtr buffer) in D:\src\pdn\src\Base\Imaging\Generated\IBitmapSource.Generated.cs:line 79

   at PaintDotNet.Data.WicFileTypeHelpers.Load(Stream input, Nullable`1 forcedContainerFormat, Nullable`1 preferredVendor, MetadataTranscoder metadataTranscoder) in D:\src\pdn\src\PaintDotNet\Data\WicFileTypeHelpers.cs:line 134

   at PaintDotNet.Data.TiffFileType.OnLoad(Stream input) in D:\src\pdn\src\PaintDotNet\Data\TiffFileType.cs:line 52

   at PaintDotNet.FileType.Load(Stream input) in D:\src\pdn\src\Data\FileType.cs:line 522

   at PaintDotNet.Functional.Func.Eval[T1,TRet](Func`2 f, T1 arg1) in D:\src\pdn\src\Base\Functional\Func.cs:line 158

NAIP_32s

Application version: paint.net 4.2.10



PaintDotNet.Imaging.BadImageException (0x88982F60): D:\src\pdn\src\SystemLayer.Native\Imaging\WICBitmapSource.cpp (170) : hr = m_pBitmapSource->CopyPixels( pSrcRectWic, static_cast<UINT>(stride), bufferSize, reinterpret_cast<BYTE*>(buffer.ToPointer()));

   at PaintDotNet.Interop.InteropErrorInfo.ThrowIfError() in D:\src\pdn\src\Base\Interop\InteropErrorInfo.cs:line 98

   at PaintDotNet.SystemLayer.Native.x64.NativeUtilities.ThrowOnErrorImpl(Int32 hr, SByte* szHr, IUnknown* pFxErrorInfo) in D:\src\pdn\src\SystemLayer.Native\NativeUtilities.cpp:line 70

   at PaintDotNet.SystemLayer.Native.x64.Imaging.WICBitmapSource.CopyPixels(Nullable`1 srcRect, Int32 stride, UInt32 bufferSize, IntPtr buffer) in D:\src\pdn\src\SystemLayer.Native\Imaging\WICBitmapSource.cpp:line 156

   at PaintDotNet.Imaging.Proxies.BitmapSourceProxy.CopyPixels(Nullable`1 srcRect, Int32 bufferStride, UInt32 bufferSize, IntPtr buffer) in D:\src\pdn\src\Base\Imaging\Generated\IBitmapSource.Generated.cs:line 79

   at PaintDotNet.Data.WicFileTypeHelpers.Load(Stream input, Nullable`1 forcedContainerFormat, Nullable`1 preferredVendor, MetadataTranscoder metadataTranscoder) in D:\src\pdn\src\PaintDotNet\Data\WicFileTypeHelpers.cs:line 134

   at PaintDotNet.Data.TiffFileType.OnLoad(Stream input) in D:\src\pdn\src\PaintDotNet\Data\TiffFileType.cs:line 52

   at PaintDotNet.FileType.Load(Stream input) in D:\src\pdn\src\Data\FileType.cs:line 522

   at PaintDotNet.Functional.Func.Eval[T1,TRet](Func`2 f, T1 arg1) in D:\src\pdn\src\Base\Functional\Func.cs:line 158

NAIP_32u

Application version: paint.net 4.2.10



PaintDotNet.Imaging.BadImageException (0x88982F60): D:\src\pdn\src\SystemLayer.Native\Imaging\WICBitmapSource.cpp (170) : hr = m_pBitmapSource->CopyPixels( pSrcRectWic, static_cast<UINT>(stride), bufferSize, reinterpret_cast<BYTE*>(buffer.ToPointer()));

   at PaintDotNet.Interop.InteropErrorInfo.ThrowIfError() in D:\src\pdn\src\Base\Interop\InteropErrorInfo.cs:line 98

   at PaintDotNet.SystemLayer.Native.x64.NativeUtilities.ThrowOnErrorImpl(Int32 hr, SByte* szHr, IUnknown* pFxErrorInfo) in D:\src\pdn\src\SystemLayer.Native\NativeUtilities.cpp:line 70

   at PaintDotNet.SystemLayer.Native.x64.Imaging.WICBitmapSource.CopyPixels(Nullable`1 srcRect, Int32 stride, UInt32 bufferSize, IntPtr buffer) in D:\src\pdn\src\SystemLayer.Native\Imaging\WICBitmapSource.cpp:line 156

   at PaintDotNet.Imaging.Proxies.BitmapSourceProxy.CopyPixels(Nullable`1 srcRect, Int32 bufferStride, UInt32 bufferSize, IntPtr buffer) in D:\src\pdn\src\Base\Imaging\Generated\IBitmapSource.Generated.cs:line 79

   at PaintDotNet.Data.WicFileTypeHelpers.Load(Stream input, Nullable`1 forcedContainerFormat, Nullable`1 preferredVendor, MetadataTranscoder metadataTranscoder) in D:\src\pdn\src\PaintDotNet\Data\WicFileTypeHelpers.cs:line 134

   at PaintDotNet.Data.TiffFileType.OnLoad(Stream input) in D:\src\pdn\src\PaintDotNet\Data\TiffFileType.cs:line 52

   at PaintDotNet.FileType.Load(Stream input) in D:\src\pdn\src\Data\FileType.cs:line 522

   at PaintDotNet.Functional.Func.Eval[T1,TRet](Func`2 f, T1 arg1) in D:\src\pdn\src\Base\Functional\Func.cs:line 158

NAIP_64

Application version: paint.net 4.2.10



PaintDotNet.Imaging.ComponentNotFoundException (0x88982F50): D:\src\pdn\src\SystemLayer.Native\Imaging\WICImagingFactory.cpp (902) : hr = m_pImagingFactory->CreateDecoderFromStream( spStream, preferredVendor.HasValue ? &NativeConversions::ToNative(preferredVendor.Value.Guid) : 0, static_cast<WICDecodeOptions>(metadataOptions), &spDecoder);

   at PaintDotNet.Interop.InteropErrorInfo.ThrowIfError() in D:\src\pdn\src\Base\Interop\InteropErrorInfo.cs:line 98

   at PaintDotNet.SystemLayer.Native.x64.NativeUtilities.ThrowOnErrorImpl(Int32 hr, SByte* szHr, IUnknown* pFxErrorInfo) in D:\src\pdn\src\SystemLayer.Native\NativeUtilities.cpp:line 70

   at PaintDotNet.SystemLayer.Native.x64.Imaging.WICImagingFactory.CreateDecoderFromStream(Stream stream, BitmapDecodeOptions metadataOptions, Nullable`1 containerFormat, Nullable`1 preferredVendor) in D:\src\pdn\src\SystemLayer.Native\Imaging\WICImagingFactory.cpp:line 906

   at PaintDotNet.Data.WicFileTypeHelpers.Load(Stream input, Nullable`1 forcedContainerFormat, Nullable`1 preferredVendor, MetadataTranscoder metadataTranscoder) in D:\src\pdn\src\PaintDotNet\Data\WicFileTypeHelpers.cs:line 61

   at PaintDotNet.Data.TiffFileType.OnLoad(Stream input) in D:\src\pdn\src\PaintDotNet\Data\TiffFileType.cs:line 52

   at PaintDotNet.FileType.Load(Stream input) in D:\src\pdn\src\Data\FileType.cs:line 522

   at PaintDotNet.Functional.Func.Eval[T1,TRet](Func`2 f, T1 arg1) in D:\src\pdn\src\Base\Functional\Func.cs:line 158

 

Link to comment
Share on other sites

33 minutes ago, Saijin_Naib said:

32bit and 64bit images fail to Import/Export

 

Paint.NET uses the TIFF functionality that is built-in to Windows (WIC).

 

33 minutes ago, Saijin_Naib said:

16bit Image (Signed / Unsigned) display in monochrome unexpectedly

 

This is most likely an artifact of converting the image to 8-bits-per-channel when it is loaded in Paint.NET.

  • Upvote 1

PdnSig.png

Plugin Pack | PSFilterPdn | Content Aware Fill | G'MICPaint Shop Pro Filetype | RAW Filetype | WebP Filetype

The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait

 

Link to comment
Share on other sites

1 hour ago, null54 said:

 

Paint.NET uses the TIFF functionality that is built-in to Windows (WIC).

 

 

This is most likely an artifact of converting the image to 8-bits-per-channel when it is loaded in Paint.NET.

I didn't see in the documentation anything specifically saying that 32bit/64bit images are or are not supported. It is possible I didn't read it properly, however.

 

Can that be avoided so the data do not get re-scaled?

Link to comment
Share on other sites

19 minutes ago, Saijin_Naib said:

I didn't see in the documentation anything specifically saying that 32bit/64bit images are or are not supported. It is possible I didn't read it properly, however.

 

Can that be avoided so the data do not get re-scaled?

 

On that subject, Rick said...

 

On 2/7/2007 at 3:59 PM, Rick Brewster said:

CMYK support, or 16-bits per pixel support -- Not gonna happen. If you really need good software for working with images for printing, or need to work at a professional level, then I must honestly point you towards Adobe Photoshop.

 

  • Upvote 1
Link to comment
Share on other sites

The NAIP_16s and NAIP_16u images also load as greyscale over in Photoshop (latest version). So, QGIS must just be interpreting the image in a non-standard/domain-specific way (AFAICT).

 

Looking at the 32-bit files next ...

  • Upvote 1

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

36 minutes ago, BoltBait said:

 

On that subject, Rick said...

 

 

And nothing has changed in the intervening 13 years? Paint.NET and WIC are in very different places than they were back then, for sure.

 

2 minutes ago, Rick Brewster said:

The NAIP_16s and NAIP_16u images also load as greyscale over in Photoshop (latest version). So, QGIS must just be interpreting the image in a non-standard/domain-specific way (AFAICT).

 

Looking at the 32-bit files next ...

Indeed, Affinity Photo also renders them grayscale, as well as Microsoft Photos (WIC). At least PDN renders the 1/2/4bit images, Affinity won't even do that with whatever TIFF library they're using.

 

I'm trying to think what QGIS, ArcGIS, and other GIS software would be doing differently to render the 16bit images in color properly... Rescaling the input values to display colors on the fly?

 

Thanks all for taking a look.

 

Link to comment
Share on other sites

16-bits per pixel component support in the FAQ specifically refers to holding that data in memory and being able to save it to files.

 

There's no issue with "importing" an image like that, it just gets truncated to 8-bits per pixel component (aka 32-bit BGRA). Greyscale images are also expanded from 1 channel to the full 4 BGRA channels.

  • Upvote 1

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Okay so it looks like WIC just can't handle these 32-bit grayscale images.

 

Using WICExplorer, it just says "nope", indicating this is nothing to do with Paint.NET specifically:

image.png

 

If I open the image in Photoshop, it works. However, over in the Channels window there seems to be extra image data attached. Like it has ... a gray channel, and then two alpha channels? Maybe this is what QGIS is using to achieve a color rendering. Still, it seems to be application- or domain-specific stuff that it's doing.

 

image.png

 

If I then re-save the image and uncheck "Alpha Channels" in the Save As dialog...

 

image.png

 

.. then that file is able to be loaded by WIC and Paint.NET.

 

I'm not really sure what these alpha channels are, but hopefully this is a clue to lead you in the right direction.

 

I don't think there's much I can do at this point other than completely rewrite the TIFF decoder to use something like LibTIFF, and I don't think there's enough ROI in spending a month (or more) on that. If someone's interested in writing a plugin then I can look at making it possible to override or supplant the built-in TIFF decoder, and then we can also talk about integration into the app (similar to DDS and WebP), but otherwise this is currently at a dead end.

  • Upvote 1

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Alright, I've filed individual issues with example data for each of the above "problem" files (16u/s, 32f/u/s, 64) with Microsoft using Feedback Hub.

 

I doubt it'll do anything, but I think this about where it gets far above my paygrade.

 

Thanks for looking into it all, Rick.

 

I'm not sure ripping out WIC for libtiff is worthwhile either...

Edited by Saijin_Naib
Link to comment
Share on other sites

3 minutes ago, Saijin_Naib said:

Alright, I've filed individual issues with example data for each of the above "problem" files (16u/s, 32f/u/s, 64) with Microsoft using Feedback Hub.

 

 

You filed the issues for Windows? Do you have a link to the reports?

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Thanks for the reports -- I've also forwarded this to the WIC team at Microsoft.

 

I think the best way forward is for someone to write a TIFF plugin that uses libTIFF instead of WIC. I can add a hidden setting (registry key) to disable the built-in TIFF handler in order to faciliate the plugin's development.

 

A simpler approach may be if someone can write (or already has) a small command-line utility to load the TIFFs and re-save them in a compatible format.

 

BTW, I tried loading the images with GIMP (2.8.22) and the results were not good.

image.png

  • Like 1

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...