/// Creates an [ImageTexture] with pixel data from an encoded image file at `path`.
Creates an [ImageTexture] with pixel data from an encoded image file at `path`.
Creates an [ ImageTexture ] with pixel data from an encoded image file at ` path ` .
pub fn from_path(path: impl AsRef<Path>, srgb: bool) -> Result<Self> {
        let image = image::open(path)?.into_rgba8();
        let (width, height) = (image.width(), image.height());
        let raw = image.into_raw();
        Ok(ImageTexture {
            format: if srgb {
                wgpu::TextureFormat::Rgba8UnormSrgb
            } else {
                wgpu::TextureFormat::Rgba8Unorm
            },
            pixels: Cow::Owned(raw),
            width,
            height,
        })
    }
pub fn from_path ( path : impl AsRef < Path > , srgb : bool ) -> Result < Self > { let image = image :: open ( path ) ? . into_rgba8 ( ) ; let ( width , height ) = ( image . width ( ) , image . height ( ) ) ; let raw = image . into_raw ( ) ; Ok ( ImageTexture { format : if srgb { wgpu :: TextureFormat :: Rgba8UnormSrgb } else { wgpu :: TextureFormat :: Rgba8Unorm } , pixels : Cow :: Owned ( raw ) , width , height , } ) }
Creates an [ImageTexture] with pixel data from an encoded image file at `path`.
Creates an [ ImageTexture ] with pixel data from an encoded image file at ` path ` .
path
impl AsRef<Path>
srgb
bool