Skip to content

Commit

Permalink
Fix bmp encoder when image has no palette
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan-duncan committed Oct 30, 2024
1 parent c4d37bd commit 2231332
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/src/formats/bmp_encoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ class BmpEncoder extends Encoder {
final rowPadding =
rowPaddingSize > 0 ? List<int>.filled(rowPaddingSize, 0xff) : null;


final implicitPaletteSize = bpp >= 1 && bpp <= 8 ? 1 << bpp : 0;

final imageFileSize = fileStride * image.height;
final headerInfoSize = bpp > 8 ? 124 : 40;
final headerSize = headerInfoSize + 14;
final paletteSize = (image.palette?.numColors ?? 0) * 4;
final paletteSize = (image.palette?.numColors ?? implicitPaletteSize) * 4;
final origImageOffset = headerSize + paletteSize;
final imageOffset = origImageOffset;
//final imageOffset = _roundToMultiple(origImageOffset);
Expand Down

0 comments on commit 2231332

Please sign in to comment.