mirror of
https://github.com/aljazceru/notedeck.git
synced 2026-02-01 14:44:21 +01:00
add load_texture_checked
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user