Saijin_Naib Posted March 31, 2020 Share Posted March 31, 2020 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 NAIP_16s (PDN) NAIP_16s (QGIS) NAIP_16u (PDN) 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 Quote Link to comment Share on other sites More sharing options...
null54 Posted March 31, 2020 Share Posted March 31, 2020 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. 1 Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint 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 More sharing options...
Saijin_Naib Posted April 1, 2020 Author Share Posted April 1, 2020 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? Quote Link to comment Share on other sites More sharing options...
BoltBait Posted April 1, 2020 Share Posted April 1, 2020 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. 1 Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game Link to comment Share on other sites More sharing options...
Rick Brewster Posted April 1, 2020 Share Posted April 1, 2020 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 ... 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Saijin_Naib Posted April 1, 2020 Author Share Posted April 1, 2020 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. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted April 1, 2020 Share Posted April 1, 2020 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. 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Rick Brewster Posted April 1, 2020 Share Posted April 1, 2020 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: 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. If I then re-save the image and uncheck "Alpha Channels" in the Save As dialog... .. 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. 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Saijin_Naib Posted April 1, 2020 Author Share Posted April 1, 2020 (edited) 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 April 1, 2020 by Saijin_Naib Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted April 1, 2020 Share Posted April 1, 2020 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? Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Saijin_Naib Posted April 1, 2020 Author Share Posted April 1, 2020 16bit Signed: https://aka.ms/AA80b4a 16bit Unsigned: https://aka.ms/AA80brw 32bit Float: https://aka.ms/AA80bry 32bit Signed: https://aka.ms/AA80bs0 32bit Unsigned: https://aka.ms/AA80bs3 64bit: https://aka.ms/AA80bs4 1 Quote Link to comment Share on other sites More sharing options...
Saijin_Naib Posted April 1, 2020 Author Share Posted April 1, 2020 (edited) I'm all ears if you have further suggestions on who/where I should keep trying to upstream this. Edited April 1, 2020 by Saijin_Naib Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted April 1, 2020 Share Posted April 1, 2020 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. 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.