Repository navigation
fix(desktop qr): decode QR images of any PNG bit depth from Select file - #1486
Merged
Merged
Conversation
sneurlax
force-pushed
the
fix/qr-image-file-decoding
branch
from
November 2, 2026 21:01
e1a39db to
fd41638
Compare
julian-CStack
force-pushed
the
fix/qr-image-file-decoding
branch
from
November 2, 2026 21:13
fd41638 to
0da4fca
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## fix/windows-qr-camera #1486 +/- ##
========================================================
Coverage ? 11.66%
========================================================
Files ? 1136
Lines ? 114344
Branches ? 0
========================================================
Hits ? 13341
Misses ? 101003
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Image.convert(numChannels: 4) keeps the source format, so a 1-bit PNG (Python qrcode's default output) stayed bit-packed and getBytes returned a quarter of the bytes RGBLuminanceSource reads. It threw a RangeError, which was swallowed and reported as "No QR code found". 16-bit PNGs failed the same way. Convert to 8-bit RGBA, build 0xAARRGGBB pixels explicitly, and composite transparency onto white. Move the decode into utilities/qr_image_decoder.dart with tests for 1-bit, 8-bit gray, palette, 16-bit, RGB, RGBA, transparent and JPEG input.
julian-CStack
force-pushed
the
fix/qr-image-file-decoding
branch
from
November 3, 2026 19:49
82ab0bf to
c41b06e
Compare
julian-CStack
approved these changes
Nov 3, 2026
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.
Base:
fix/windows-qr-camera. Second of three stacked PRs on top of the Windows QR camera fix."Select file" in the desktop QR dialog reports "No QR code found in the image" for some valid QR images, on every desktop platform.
Cause
The dialog built zxing's
RGBLuminanceSourcefromimage.convert(numChannels: 4).convert()keeps the source bit depth unless told otherwise, so a 1-bit PNG (Python qrcode's default output) stays bit-packed, and a 16-bit PNG keeps two bytes per channel. The bytes handed to zxing then don't match width x height pixels, it throws a RangeError, and the dialog swallows that as "no QR code". A dark code on a transparent background also has no light background once the alpha channel is dropped.Change
lib/utilities/qr_image_decoder.dart:decodeQrFromImageconverts any decoded image to 8-bit RGBA (which also resolves palettes) before building the luminance source.HybridBinarizer, thenGlobalHistogramBinarizer, as the dialog already did.decodeQrFromImageBytesdecodes encoded bytes first and returns null for anything that isn't an image._scanImagecallsdecodeQrFromImage, so camera frames and "Select file" share one decode path.test/utilities/qr_image_decoder_test.dart, covering: