notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 8da999998ab8d5ceff9ca51b3d37bb136acdc2d5
parent b632d6fbc00ca62a97421d06fcee384698d56969
Author: kernelkind <kernelkind@gmail.com>
Date:   Fri,  3 Oct 2025 16:10:04 -0400

add `load_texture_checked`

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Mcrates/notedeck/src/media/mod.rs | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/crates/notedeck/src/media/mod.rs b/crates/notedeck/src/media/mod.rs @@ -10,6 +10,7 @@ pub use blur::{ compute_blurhash, update_imeta_blurhashes, ImageMetadata, ObfuscationType, PixelDimensions, PointDimensions, }; +use egui::{ColorImage, TextureHandle}; pub use images::ImageType; pub use renderable::RenderableMedia; @@ -33,3 +34,18 @@ impl AnimationMode { // max size wgpu can handle without panicing pub const MAX_SIZE_WGPU: usize = 8192; + +pub fn load_texture_checked( + ctx: &egui::Context, + name: impl Into<String>, + image: ColorImage, + options: egui::TextureOptions, +) -> TextureHandle { + let size = image.size; + + if size[0] > MAX_SIZE_WGPU || size[1] > MAX_SIZE_WGPU { + panic!("The image MUST be less than or equal to {MAX_SIZE_WGPU} pixels in each direction"); + } + + ctx.load_texture(name, image, options) +}