Skip to content

Commit

Permalink
Merge pull request #80 from LedgerHQ/y333_091224/fix_color_inversion
Browse files Browse the repository at this point in the history
  • Loading branch information
yogh333 authored Dec 9, 2024
2 parents e14223b + c8f3fb0 commit 7cf7832
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.5.2] - 2024-12-09

### Fixed

- For Nano S+ and X, B&W color shall be inverted

## [0.5.1] - 2024-08-23

### Fixed
Expand Down
9 changes: 6 additions & 3 deletions ledgerwallet/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def is_power2(n):
return n != 0 and ((n & (n - 1)) == 0)


def _image_to_buffer_nbgl(im: Image, compress: bool) -> bytes:
def _image_to_buffer_nbgl(im: Image, compress: bool, reverse_1bpp: bool) -> bytes:
im = im.convert("L")
nb_colors = len(im.getcolors())

Expand Down Expand Up @@ -59,6 +59,9 @@ def _image_to_buffer_nbgl(im: Image, compress: bool) -> bytes:
if color_index >= nb_colors:
color_index = nb_colors - 1

if bpp == 1 and reverse_1bpp:
color_index = (color_index + 1) & 0x1

# le encoded
current_byte += color_index << ((8 - bpp) - current_bit)
current_bit += bpp
Expand Down Expand Up @@ -199,7 +202,7 @@ def icon_from_file(image_file: str, device: str, api_level: Optional[int]) -> by
DeviceNames.LEDGER_STAX.value,
DeviceNames.LEDGER_FLEX.value,
]:
image_data = _image_to_buffer_nbgl(im, True)
image_data = _image_to_buffer_nbgl(im, True, False)

elif (
get_device_name(int(device, 16))
Expand All @@ -210,7 +213,7 @@ def icon_from_file(image_file: str, device: str, api_level: Optional[int]) -> by
and api_level is not None
and api_level > 5
):
image_data = _image_to_buffer_nbgl(im, False)
image_data = _image_to_buffer_nbgl(im, False, True)
else:
image_data = _image_to_packed_buffer_bagl(im)

Expand Down

0 comments on commit 7cf7832

Please sign in to comment.