Jump to content

Recommended Posts

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.

Link to post
Share on other sites

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.

Link to post
Share on other sites

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.

Link to post
Share on other sites

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?

Link to post
Share on other sites
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.

Link to post
Share on other sites
  • 2 weeks later...

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.

Link to post
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.

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