Skip to content

Commit

Permalink
Merge pull request #15 from rokm/fix-palette-bitdepth-switch
Browse files Browse the repository at this point in the history
PngBuilder: fix switch from 4-bit to 8-bit palette
  • Loading branch information
EliotJones authored Oct 13, 2023
2 parents ac862d6 + 6166486 commit 3dbdf20
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/BigGustave/PngBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public void Save(Stream outputStream, SaveOptions options = null)
if (!hasTooManyColorsForPalette && !hasAlphaChannel)
{
var paletteColors = colorCounts.OrderByDescending(x => x.Value).Select(x => x.Key).ToList();
bitDepth = paletteColors.Count >= 128 ? 8 : 4;
bitDepth = paletteColors.Count > 16 ? 8 : 4;
var samplesPerByte = bitDepth == 8 ? 1 : 2;
var applyShift = samplesPerByte == 2;

Expand Down

0 comments on commit 3dbdf20

Please sign in to comment.