Module large_image

Module large_image 

Source

Structs§

LargeImageManager
Manages state and operations for large image decoding in gallery mode

Constants§

ATLAS_FRAGMENT_SIZE
Threshold for considering an image “large” requiring GPU tiling Atlas fragment/tile size in pixels. Large images are split into fragments of this size. Must match the atlas SIZE constant in libcosmic/iced/wgpu/src/image/atlas.rs
DECIMAL_MB_TO_BYTES
Conversion factor: 1 MB = 1000 * 1000 bytes (decimal megabyte, used by image crate) The image crate’s memory limits use decimal MB, not binary MB.
DISPLAY_SCALE_FACTOR 🔒
Scale factor for HiDPI displays - decode at higher resolution than display size for better quality on high-DPI screens. 1.5x provides good balance between quality and memory usage and also prevets re-decoding on small windows size adjustments.
GALLERY_MEMORY_LIMIT_MB 🔒
Maximum memory allocation for gallery image decoding in MB. Gallery mode uses the full memory budget since only one image decodes at a time. This matches the ThumbCfg max_mem_mb budget for consistency.
MB_TO_BYTES
Conversion factor: 1 MB = 1024 * 1024 bytes (binary megabyte, used for RAM calculations)
RGBA_BYTES_PER_PIXEL
Bytes per pixel in RGBA format (Red, Green, Blue, Alpha = 4 bytes)
SYSTEM_MEMORY_RESERVE_MB 🔒
System memory reserve in MB to maintain for system stability (prevents thrashing) Note: RAM checking is currently only available on Linux via procfs. On Windows and macOS, only GPU buffer limits are enforced.

Functions§

calculate_image_memory 🔒
Calculate the memory required to decode an image in bytes. Returns None if the calculation overflows.
calculate_target_dimensions
Calculate optimal target dimensions for decoding based on display size. Returns None if no resizing is needed (image is smaller than display).
check_memory_available
check_ram_available 🔒
Check if there’s sufficient system RAM to decode an image (Linux only). Returns: (has_memory, error_message)
decode_large_image
Decode a large image asynchronously in a blocking thread pool.
exceeds_memory_limit
Check if an image’s dimensions would exceed the available memory budget. Returns true if the image is too large to decode.
get_image_dimensions
Get the dimensions of an image without fully decoding it
should_use_dedicated_worker
Determine if an image should use the dedicated worker for thumbnail generation. Returns (use_dedicated_worker, effective_max_mb, effective_jobs).
should_use_tiling
Check if an image should use GPU tiling for display. Images larger than the atlas fragment size need to be split into tiles for GPU upload.