Jump to content

Images already with 256 or fewer colors being dithered when saved with palette


Recommended Posts

Images that already have 256 or fewer colors, whether as a result being converted to grayscale or being from a format with a palette, are being dithered unnecessarily on save. I believe this is a regression in 4.2.16. This is particularly concerning because it makes Auto-detect lossy for these PNGs.

 

The following PNG-8 and GIF were generated externally:

 test.png.5169e0b3e49f6be0a173e875f2d2562e.png test.gif.083c1350b3de5c378c3f1a61f7c69173.gif

The files after being opened and saved with default settings in paint.net:

 test2.png.87bca7bc3331f9eb90e6d7dda2da56d8.png test2.gif.db37af07cf2e33690ef1c35e473636d8.gif

There is now noticeable dithering on the previously solid square.

dithering.thumb.png.ff3d16035f2b14bdf4dea3aa37abd64a.png

  • Upvote 1
Link to comment
Share on other sites

I can confirm this is a bug -- there's a bug in the code that chooses colors from the palette table. When the palette is an exact match, the color chosen should also always be an exact match, but it's not. This introduces error, which then causes dithering. I'll look into it for the 4.2.17 update.

  • 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

Alright I've found the culprit. It seems to be due to floating-point precision. Simple as that. Should be easy enough to fix, and probably won't even have a performance hit (not that it matters with an image of this size) due to the new stuff provided in .NET 5 (which 4.2.17 has migrated to).

  • Like 1
  • You're a Smart Cookie! 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

  • 4 weeks later...

Sorry to necro but why is this still not pushed as a critical update? I've been converting hundreds of old scanned 8-bit BMP documents into PNGs using Paint.NET over the past 5 months and only now do I learn that all the conversions I've done since around April/May have quality losses in them! Which, by the way, I can't redo since I deleted the originals because I had foolishly assumed that something as basic as saving fully lossless PNGs was a safe and reliable operation for an image editor in 2021.

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