Jump to content

Autodetect bit depth on saving .png files fails on beta 4.216.7765.43041


Recommended Posts

This can be reproduced as follows: make a transparent image and paint on it with < 256 colors without antialiasing, ensuring 1-bit transparency depth. If there is partial transparency or the number of colors is sufficiently high, this exception does not occur. 

 

Attached is an image that's been saved as 32-bit, trying to resave it as autodetect fails.

 

temp.png.a51299c57e1f64f5e3f28493d8a2f5a1.png

Exception:

System.ArgumentException: palette colors must be opaque (A=255), although 1 transparent color as the last entry is permitted
   at PaintDotNet.Imaging.PaletteMap..ctor(IEnumerable`1 colors) in D:\src\pdn\src\Framework\Imaging\PaletteMap.cs:line 27
   at PaintDotNet.Imaging.ProximityPaletteMap..ctor(IEnumerable`1 palette) in D:\src\pdn\src\Framework\Imaging\ProximityPaletteMap.cs:line 46
   at PaintDotNet.Data.WicFileTypeHelpers.Save(IBitmapSource`1 sourceBgra32, Vector2Double dpi, Metadata metadata, Stream output, ContainerFormat containerFormat, Nullable`1 preferredVendor, IMetadataTranscoder metadataTranscoder, IEnumerable`1 encoderOptions, SavableBitDepths bitDepth, IReadOnlyList`1 paletteForIndexed, Int32 ditherLevelForIndexed, ProgressEventHandler progressCallback, Object progressCallbackSender) in D:\src\pdn\src\PaintDotNet\Data\WicFileTypeHelpers.cs:line 290
   at PaintDotNet.Data.PngFileType.OnFinalSave(Document input, Stream output, Surface flattenedImage, SavableBitDepths bitDepth, IReadOnlyList`1 paletteColors, Int32 ditherLevel, PropertyBasedSaveConfigToken token, ProgressEventHandler progressCallback) in D:\src\pdn\src\PaintDotNet\Data\PngFileType.cs:line 263
   at PaintDotNet.Data.InternalFileType.FinalSave(Document input, Stream output, Surface scratchSurface, SavableBitDepths bitDepth, QuantizationAlgorithm quantizationAlgorithm, Int32 alphaThreshold, Int32 ditherLevel, ImageColorsAnalysis analysis, PropertyBasedSaveConfigToken token, ProgressEventHandler progressCallback, Double progressStart, Double progressEnd) in D:\src\pdn\src\PaintDotNet\Data\InternalFileType.cs:line 510
   at PaintDotNet.Data.InternalFileType.GetSavableBitDepthFileLength(SavableBitDepths bitDepth, Document input, Surface scratchSurface, QuantizationAlgorithm quantizationAlgorithm, Int32 ditherLevel, Int32 alphaThreshold, PropertyBasedSaveConfigToken token, ProgressEventHandler progressCallback, Double progressStart, Double progressEnd) in D:\src\pdn\src\PaintDotNet\Data\InternalFileType.cs:line 454
   at PaintDotNet.Data.InternalFileType.ChooseBitDepth(Document input, Surface scratchSurface, QuantizationAlgorithm quantizationAlgorithm, Int32 ditherLevel, Int32 alphaThreshold, PropertyBasedSaveConfigToken token, ProgressEventHandler progressCallback, Double progressStart, Double progressEnd, HashSet`1 allowedBitDepths, HashSet`1 losslessBitDepths, ImageColorsAnalysis analysis) in D:\src\pdn\src\PaintDotNet\Data\InternalFileType.cs:line 346
   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 167
   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 261
   at PaintDotNet.Dialogs.SaveConfigDialog.<>c__DisplayClass49_0.<UpdatePreviewAsync>b__0() in D:\src\pdn\src\PaintDotNet\Dialogs\SaveConfigDialog.cs:line 613
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PaintDotNet.Dialogs.SaveConfigDialog.<UpdatePreviewAsync>d__49.MoveNext() in D:\src\pdn\src\PaintDotNet\Dialogs\SaveConfigDialog.cs:line 632

 

Edited by frio
added image that reproduces the bug
  • Upvote 2
Link to comment
Share on other sites

Aha, this is easy for me to reproduce, thanks! I'll get it fixed asap.

 

Looks like the same issue reported by @HopperElec over here, https://forums.getpaint.net/topic/118070-paintnet-4216-beta-build-7765/?do=findComment&comment=582506, but their sample image didn't reproduce this for me.

 

  • Upvote 2

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

Tested, saves the files it used to previously stumble on with autodetect. Thanks!

 

(And I have to take this opportunity to add: thanks for all these ~15 years paint.net has been an indispensable tool for my purposes, over all kinds of Photoshops and what have you.)

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