MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / load_image

Method load_image

shared.py:1730–1746  ·  view source on GitHub ↗

Load an image, optionally resizing it by the given scale factor.

(self, image_path, scale=None)

Source from the content-addressed store, hash-verified

1728 logger.error(f"Error loading font {font_name}: {e}")
1729 raise
1730
1731 def _get_image_scale(self):
1732 """Get the image scale factor for the current display.
1733 For small displays (2.13", 2.7") icons stay at native size.
1734 For large displays (4.26" 800x480) icons scale up proportionally."""
1735 sy = getattr(self, 'scale_factor_y', 1.0)
1736 if sy > 1.5: # Large display (e.g. 4.26")
1737 return sy
1738 return 1.0
1739
1740 def load_images(self):
1741 """Load the images for the e-paper display, scaled for display size."""
1742 try:
1743 logger.info("Loading images...")
1744 img_scale = self._get_image_scale()
1745
1746 # Load static images from the root of staticpicdir
1747 self.ragnarstatusimage = None
1748 self.ragnar1 = self.load_image(os.path.join(self.staticpicdir, 'ragnar1.bmp'), scale=img_scale)
1749 self.port = self.load_image(os.path.join(self.staticpicdir, 'port.bmp'), scale=img_scale)

Callers 1

load_imagesMethod · 0.95

Calls 4

warningMethod · 0.80
openMethod · 0.80
resizeMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected