Skip to content

Commit 18d68cd

Browse files
committed
Optimize NFT image loading method
1 parent d6b021d commit 18d68cd

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

core/src/trezor/lvglui/scrs/nftmanager.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,29 @@ def __init__(self, prev_scr, nft_config, file_name):
437437
self.trash_icon.add_flag(lv.obj.FLAG.EVENT_BUBBLE) # Enable event bubbling
438438

439439
# Main NFT image (456x456 as requested)
440-
self.nft_image = lv.img(self.content_area)
440+
# Use a container with clip_corner to avoid edge artifacts on the image
441+
self.nft_image_container = lv.obj(self.content_area)
442+
self.nft_image_container.set_size(456, 456)
443+
self.nft_image_container.align(lv.ALIGN.TOP_MID, 0, 128)
444+
self.nft_image_container.add_style(
445+
StyleWrapper()
446+
.radius(20)
447+
.clip_corner(True)
448+
.bg_color(lv_colors.BLACK)
449+
.bg_opa(lv.OPA.COVER)
450+
.border_width(0)
451+
.pad_all(0),
452+
0,
453+
)
454+
self.nft_image_container.clear_flag(lv.obj.FLAG.SCROLLABLE)
455+
self.nft_image_container.clear_flag(lv.obj.FLAG.CLICKABLE)
456+
self.nft_image_container.add_flag(lv.obj.FLAG.EVENT_BUBBLE)
457+
458+
self.nft_image = lv.img(self.nft_image_container)
441459
self.nft_image.set_src(self.img_path)
442-
self.nft_image.set_size(456, 456)
443-
self.nft_image.align(lv.ALIGN.TOP_MID, 0, 128) # Position image 128px from top
444-
self.nft_image.add_style(StyleWrapper().radius(20).clip_corner(True), 0)
460+
# Use zoom instead of set_size to scale 480x480 -> 456x456 (zoom = 456/480*256 = 243)
461+
self.nft_image.set_zoom(243)
462+
self.nft_image.align(lv.ALIGN.CENTER, 0, 0)
445463

446464
# Title text below image
447465
self.nft_title = lv.label(self.content_area)
@@ -455,7 +473,9 @@ def __init__(self, prev_scr, nft_config, file_name):
455473
.text_align(lv.TEXT_ALIGN.LEFT),
456474
0,
457475
)
458-
self.nft_title.align_to(self.nft_image, lv.ALIGN.OUT_BOTTOM_LEFT, 12, 12)
476+
self.nft_title.align_to(
477+
self.nft_image_container, lv.ALIGN.OUT_BOTTOM_LEFT, 12, 12
478+
)
459479

460480
# Description text below title
461481
self.nft_description = lv.label(self.content_area)

0 commit comments

Comments
 (0)