use crate::{Context, Image, Pt};
pub fn from_image(ctx: &mut Context, image: &image::DynamicImage) -> anyhow::Result<Image> {
let rgba = image.to_rgba8();
from_rgba_image(ctx, &rgba)
}
pub fn from_rgba_image(ctx: &mut Context, image: &image::RgbaImage) -> anyhow::Result<Image> {
let width_px = image.width();
let height_px = image.height();
let scale_factor = ctx.scale_factor().max(1.0);
let width = Pt::from_physical_px(width_px as f64, scale_factor);
let height = Pt::from_physical_px(height_px as f64, scale_factor);
Image::new_from_rgba8_with_pixels(ctx, width_px, height_px, width, height, image.as_raw())
}