Repository navigation
fix: preserve NativeImage scale factor when serializing single representations - #277
Merged
Merged
Conversation
…entations For an image with a single representation, serializeNativeImage sent the raw bitmap from toBitmap() (physical pixels) together with getSize() (DIPs). deserializeNativeImage passed that DIP size to addRepresentation, which reads a raw buffer as width x height pixels, so any image whose scale factor was not 1 arrived with the wrong dimensions and scrambled pixels, in both directions. Keep the raw bitmap at scale factor 1 and send a PNG otherwise. addRepresentation decodes PNG buffers first and takes the dimensions from the PNG itself, so deserialization needs no change. Fixes #276 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PiGRtBhKem5mLgG1cSay1b
MarshallOfSound
approved these changes
Oct 31, 2026
MarshallOfSound
marked this pull request as ready for review
October 31, 2026 19:48
MarshallOfSound
enabled auto-merge (squash)
October 31, 2026 19:49
erickzhao
approved these changes
Nov 2, 2026
|
🎉 This PR is included in version 2.1.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested via Slack thread
A NativeImage with a single representation at a scale factor other than 1 came out of remote with the wrong size and scrambled pixels, because serialization sent the bitmap's physical pixels together with the image's DIP size, and the receiving side rebuilt the buffer using those mismatched dimensions. This change sends such images as PNG instead, so the dimensions travel inside the encoding; Electron's
addRepresentationalready tries PNG decoding first, so deserialization is unchanged, and scale-1 images keep the existing raw bitmap path. New specs round-trip 1.5x and 2x images both directly and over remote in each direction, and they fail without the fix. Credit to @andersk for the diagnosis and for validating this approach at scale factors 1, 1.25, 1.5 and 2 in the issue.Fixes #276
Generated by Claude Code