diff --git a/adafruit_pycamera/__init__.py b/adafruit_pycamera/__init__.py index 1c6ad6f..45dcb3c 100644 --- a/adafruit_pycamera/__init__.py +++ b/adafruit_pycamera/__init__.py @@ -240,6 +240,7 @@ def __init__(self) -> None: # pylint: disable=too-many-statements self.combined_bmp = None self.preview_scale = None self.overlay_position = [None, None] + self.overlay_scale = 1.0 self.splash = displayio.Group() # Reset display and I/O expander @@ -929,13 +930,15 @@ def blit_overlay_into_last_capture(self): self.decoder.decode(photo_bitmap, scale=0, x=0, y=0) - bitmaptools.blit( + bitmaptools.rotozoom( photo_bitmap, self.overlay_bmp, - self.overlay_position[0] if self.overlay_position[0] is not None else 0, - self.overlay_position[1] if self.overlay_position[1] is not None else 0, - skip_source_index=self.overlay_transparency_color, - skip_dest_index=None, + ox=self.overlay_position[0] if self.overlay_position[0] is not None else 0, + oy=self.overlay_position[1] if self.overlay_position[1] is not None else 0, + px=0 if self.overlay_position[0] is not None else None, + py=0 if self.overlay_position[1] is not None else None, + skip_index=self.overlay_transparency_color, + scale=self.overlay_scale, ) cc565_swapped = ColorConverter(input_colorspace=Colorspace.RGB565_SWAPPED) @@ -1007,7 +1010,7 @@ def blit(self, bitmap, x_offset=0, y_offset=32): bitmaptools.rotozoom( self.combined_bmp, self.overlay_bmp, - scale=self.preview_scale, + scale=self.preview_scale * self.overlay_scale, skip_index=self.overlay_transparency_color, ox=int(self.overlay_position[0] * self.preview_scale) if self.overlay_position[0] is not None diff --git a/examples/overlay/code_select.py b/examples/overlay/code_select.py index 441433d..665d4e2 100644 --- a/examples/overlay/code_select.py +++ b/examples/overlay/code_select.py @@ -11,6 +11,12 @@ import traceback import adafruit_pycamera # pylint: disable=import-error +MODE_POSITION = 0 +MODE_SCALE = 1 +CURRENT_MODE = 0 + +int_scale = 100 + pycam = adafruit_pycamera.PyCamera() pycam.mode = 0 # only mode 0 (JPEG) will work in this example @@ -49,16 +55,34 @@ print(f"changing overlay to {overlay_files[cur_overlay_idx]}") pycam.overlay = f"/sd/overlays/{overlay_files[cur_overlay_idx]}" - if not pycam.down.value: - pycam.overlay_position[1] += 1 * (int(pycam.down.current_duration / 0.3) + 1) - if not pycam.up.value: - pycam.overlay_position[1] -= 1 * (int(pycam.up.current_duration / 0.3) + 1) - - if not pycam.left.value: - pycam.overlay_position[0] -= 1 * (int(pycam.left.current_duration / 0.3) + 1) - if not pycam.right.value: - pycam.overlay_position[0] += 1 * (int(pycam.right.current_duration / 0.3) + 1) + if CURRENT_MODE == MODE_POSITION: + if not pycam.down.value: + pycam.overlay_position[1] += 1 * ( + int(pycam.down.current_duration / 0.3) + 1 + ) + if not pycam.up.value: + pycam.overlay_position[1] -= 1 * (int(pycam.up.current_duration / 0.3) + 1) + if not pycam.left.value: + pycam.overlay_position[0] -= 1 * ( + int(pycam.left.current_duration / 0.3) + 1 + ) + if not pycam.right.value: + pycam.overlay_position[0] += 1 * ( + int(pycam.right.current_duration / 0.3) + 1 + ) + if CURRENT_MODE == MODE_SCALE: + if pycam.down.fell: + int_scale -= 10 + pycam.overlay_scale = int_scale / 100 + print(pycam.overlay_scale) + if pycam.up.fell: + int_scale += 10 + pycam.overlay_scale = int_scale / 100 + print(pycam.overlay_scale) + if pycam.ok.fell: + CURRENT_MODE = MODE_POSITION if CURRENT_MODE == MODE_SCALE else MODE_SCALE + print(f"Changing mode to: {CURRENT_MODE}") if pycam.shutter.short_count: print("Shutter released") pycam.tone(1200, 0.05)
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: