ViliamF Posted August 21, 2020 Share Posted August 21, 2020 I am trying to save a 59049*59049 px image, but it gives me this error: Application version: paint.net 4.2.13 System.OverflowException: D:\src\pdn\src\SystemLayer.Native\Imaging\WICImagingFactory.cpp (1194) : hr = spPalette->InitializeFromBitmap( spBitmap, static_cast<UINT>(colorCount), addTransparentColor); 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) at PaintDotNet.SystemLayer.Native.x64.Imaging.WICImagingFactory.CreatePaletteFromBitmap(IBitmapSource bitmap, Int32 colorCount, Boolean addTransparentColor) at PaintDotNet.Data.WicFileTypeHelpers.Save(Document document, Surface flattenedSurface, Stream output, ContainerFormat containerFormat, Nullable`1 preferredVendor, IMetadataTranscoder metadataTranscoder, IEnumerable`1 encoderOptions, SavableBitDepths bitDepth, Int32 ditherLevelForIndexed, ProgressEventHandler progressCallback, Object progressCallbackSender) in D:\src\pdn\src\PaintDotNet\Data\WicFileTypeHelpers.cs:line 308 at PaintDotNet.Data.PngFileType.OnFinalSave(Document input, Stream output, Surface flattenedImage, SavableBitDepths bitDepth, Int32 ditherLevel, PropertyBasedSaveConfigToken token, ProgressEventHandler progressCallback) in D:\src\pdn\src\PaintDotNet\Data\PngFileType.cs:line 241 at PaintDotNet.Data.InternalFileType.FinalSave(Document input, Stream output, Surface scratchSurface, Int32 ditherLevel, Int32 alphaThreshold, SavableBitDepths bitDepth, PropertyBasedSaveConfigToken token, ProgressEventHandler progressCallback, Double progressStart, Double progressEnd) in D:\src\pdn\src\PaintDotNet\Data\InternalFileType.cs:line 534 at PaintDotNet.Data.InternalFileType.OnSaveT(Document input, Stream output, PropertyBasedSaveConfigToken token, Surface scratchSurface, ProgressEventHandler progressCallback) in D:\src\pdn\src\PaintDotNet\Data\InternalFileType.cs:line 494 at PaintDotNet.FileType.Save(Document input, Stream output, SaveConfigToken token, Surface scratchSurface, ProgressEventHandler callback, Boolean rememberToken) in D:\src\pdn\src\Data\FileType.cs:line 278 at PaintDotNet.Controls.DocumentWorkspace.<>c__DisplayClass246_1.<DoSaveImpl>b__6() in D:\src\pdn\src\PaintDotNet\Controls\DocumentWorkspace.cs:line 2794 at PaintDotNet.Functional.Func.Try(Action f) in D:\src\pdn\src\Base\Functional\Func.cs:line 174 It should not have problems with anything, meaning it should have enough RAM (64 GB), and anything it would need, as I have succesfully saved the same file on the same computer in some previous version of the program. Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted August 21, 2020 Share Posted August 21, 2020 Not all file types can handle all sizes of images, mind you. Sometimes due to the format, sometimes due to inadequacies or bugs in the underlying system codec. However, In this particular case, it looks like WIC* is having trouble generating an 8-bit palette (or maybe 4-bit). This is part of the "Bit depth: Auto-detect" functionality in Paint.NET. The good news is that I was able to reproduce this, and the even better news is that I was able to save the image just fine by manually choosing 32-bit for the Bit Depth (24-bit is also a good choice if your image has no transparency/alpha). I may be able to fix this for the next update (4.2.14) so Paint.NET will automatically forget about trying to use 8-bit if it bumps into this error from WIC. * WIC = Windows Imaging Component. It's part of Windows. 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 August 22, 2020 Share Posted August 22, 2020 So for now you can't save any indexed format (8-bit, 4-bit, 2-bit, 1-bit) that's "too large". Seems to be around 26,500 x 26,500 pixels is the cut-off. I'm trying to find a way to make those work, too. You should see the fix in the upcoming 4.2.14 alpha. 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...
ViliamF Posted August 22, 2020 Author Share Posted August 22, 2020 I was trying to save it with 1-bit setting, as it decreases the file size. Image is simply a black-and-white Sierpinski carpet. I would be very grateful if you'd managed to make it work for 1-bit depth. Also, I would like to ask, why can't I copy a file of that size into the RAM? (I have noticed this in past versions) It is about 3,5 billion pixels, and if every pixel was represented by a byte, it would be only about 3,5 GB of RAM. Is it because pixels are represented by much more than a byte, or? Quote Link to comment Share on other sites More sharing options...
null54 Posted August 22, 2020 Share Posted August 22, 2020 29 minutes ago, ViliamF said: Also, I would like to ask, why can't I copy a file of that size into the RAM? (I have noticed this in past versions) It is about 3,5 billion pixels, and if every pixel was represented by a byte, it would be only about 3,5 GB of RAM. Each pixel in Paint.NET uses 4 bytes. 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...
Rick Brewster Posted August 22, 2020 Share Posted August 22, 2020 I would be very grateful if you'd managed to make it work for 1-bit depth. Once I make it work for 8-bit, then 4, 2, and 1-bit are no problem. 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...
ViliamF Posted August 31, 2020 Author Share Posted August 31, 2020 Thank you for the fix. I have one more "feature request" for you: It would be very helpful if I could set the color depth when opening new picture, so that instead of 4 bytes per pixel, I can directly use 1-bit depth. Quote 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.