Skip to content

Fix 16-bit binary PBM sample byte order - #3164

Merged
JimBobSquarePants merged 1 commit into
mainfrom
js/fix-pbm-16bit-endianness
Aug 8, 2026
Merged

Fix 16-bit binary PBM sample byte order#3164
JimBobSquarePants merged 1 commit into
mainfrom
js/fix-pbm-16bit-endianness

Conversation

@JimBobSquarePants

Copy link
Copy Markdown
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

The binary PGM and PPM formats store 16-bit samples most significant byte first. The decoder and encoder read and wrote them in native little-endian order, so every wide sample was byte swapped. This corrects the swizzled colors reported for 16-bit PPM images.

  • Reverse the sample byte order in BinaryDecoder and BinaryEncoder.
  • Fix integer division in the max pixel value upscale factor.
  • Add exact-value, reference-decoder, upscale, and round-trip tests.
  • Add a 16-bit PPM test image and its Magick-anchored reference PNG.
  • Document the binary decoder and encoder in full.

The binary PGM and PPM formats store 16-bit samples most significant
byte first. The decoder and encoder read and wrote them in native
little-endian order, so every wide sample was byte swapped. This
corrects the swizzled colors reported for 16-bit PPM images.

- Reverse the sample byte order in BinaryDecoder and BinaryEncoder.
- Fix integer division in the max pixel value upscale factor.
- Add exact-value, reference-decoder, upscale, and round-trip tests.
- Add a 16-bit PPM test image and its Magick-anchored reference PNG.
- Document the binary decoder and encoder in full.
@JimBobSquarePants JimBobSquarePants added this to the v4.1.0 milestone Aug 8, 2026
@JimBobSquarePants
JimBobSquarePants merged commit d2873f8 into main Aug 8, 2026
12 checks passed
@JimBobSquarePants
JimBobSquarePants deleted the js/fix-pbm-16bit-endianness branch August 8, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant