Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7bce504

Browse files
Camera: scale to fill screen
1 parent4f2e3a3 commit7bce504

File tree

1 file changed

+15
-0
lines changed
  • internal_filesystem/apps/com.micropythonos.camera/assets

1 file changed

+15
-0
lines changed

‎internal_filesystem/apps/com.micropythonos.camera/assets/camera_app.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def onResume(self, screen):
116116
print(f"camera app: webcam exception:{e}")
117117
ifself.cam:
118118
print("Camera app initialized, continuing...")
119+
self.set_image_size()
119120
self.capture_timer=lv.timer_create(self.try_capture,100,None)
120121
self.status_label_cont.add_flag(lv.obj.FLAG.HIDDEN)
121122
ifself.scanqr_mode:
@@ -139,6 +140,20 @@ def onStop(self, screen):
139140
self.cam.deinit()
140141
print("camera app cleanup done.")
141142

143+
defset_image_size(self):
144+
target_h=mpos.ui.vertical_resolution
145+
target_w=target_h
146+
iftarget_w==self.widthandtarget_h==self.height:
147+
print("Target width and height are the same as native image, no scaling required.")
148+
return
149+
print(f"scaling to size:{target_w}x{target_h}")
150+
scale_factor_w=round(target_w*256/self.width)
151+
scale_factor_h=round(target_h*256/self.height)
152+
print(f"scale_factors:{scale_factor_w},{scale_factor_h}")
153+
self.image.set_size(target_w,target_h)
154+
#self.image.set_scale(max(scale_factor_w,scale_factor_h)) # fills the entire screen but cuts off borders
155+
self.image.set_scale(min(scale_factor_w,scale_factor_h))
156+
142157
defqrdecode_one(self):
143158
try:
144159
importqrdecode

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp