add load_texture_checked

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-10-03 16:10:04 -04:00
parent b632d6fbc0
commit 8da999998a

View File

@@ -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)
}