pub fn encode_load_texture_from_image(
    device: &wgpu::Device,
    encoder: &mut wgpu::CommandEncoder,
    usage: wgpu::TextureUsage,
    image: &image::DynamicImage,
) -> wgpu::Texture {
    use image::DynamicImage::*;
    match image {
        ImageLuma8(img) => encode_load_texture_from_image_buffer(device, encoder, usage, img),
        ImageLumaA8(img) => encode_load_texture_from_image_buffer(device, encoder, usage, img),
        ImageRgba8(img) => encode_load_texture_from_image_buffer(device, encoder, usage, img),
        ImageBgra8(img) => encode_load_texture_from_image_buffer(device, encoder, usage, img),
        ImageLuma16(img) => encode_load_texture_from_image_buffer(device, encoder, usage, img),
        ImageLumaA16(img) => encode_load_texture_from_image_buffer(device, encoder, usage, img),
        ImageRgba16(img) => encode_load_texture_from_image_buffer(device, encoder, usage, img),
        ImageRgb8(_img) => {
            let img = image.to_rgba();
            encode_load_texture_from_image_buffer(device, encoder, usage, &img)
        }
        ImageBgr8(_img) => {
            let img = image.to_bgra();
            encode_load_texture_from_image_buffer(device, encoder, usage, &img)
        }
        ImageRgb16(_img) => {
            // TODO: I think we lose some quality here - e.g. 16-bit channels down to 8-bit??.
            let img = image.to_rgba();
            encode_load_texture_from_image_buffer(device, encoder, usage, &img)
        }
    }
}
/// Encode the necessary commands to load a texture directly from a dynamic image.
///
/// If the image is already in a format supported by wgpu, no conversions are performed and the
/// image is loaded directly as-is with a texture format that matches the original image color
/// type.
///
/// If the image is of an unsupported format, it will be converted to the closest supported format
/// before being uploaded.
///
/// NOTE: The returned texture will remain empty until the given `encoder` has its command buffer
/// submitted to the given `device`'s queue.
Encode the necessary commands to load a texture directly from a dynamic image.
If the image is already in a format supported by wgpu, no conversions are performed and the
image is loaded directly as-is with a texture format that matches the original image color
type.

If the image is of an unsupported format, it will be converted to the closest supported format
before being uploaded.

The returned texture will remain empty until the given `encoder` has its command buffer
submitted to the given `device`'s queue.
Encode the necessary commands to load a texture directly from a dynamic image . If the image is already in a format supported by wgpu no conversions are performed and the image is loaded directly as - is with a texture format that matches the original image color type . If the image is of an unsupported format it will be converted to the closest supported format before being uploaded . The returned texture will remain empty until the given ` encoder ` has its command buffer submitted to the given ` device ` ' s queue .
pub fn encode_load_texture_from_image(
    device: &wgpu::Device,
    encoder: &mut wgpu::CommandEncoder,
    usage: wgpu::TextureUsage,
    image: &image::DynamicImage,
) -> wgpu::Texture {
    use image::DynamicImage::*;
    match image {
        ImageLuma8(img) => encode_load_texture_from_image_buffer(device, encoder, usage, img),
        ImageLumaA8(img) => encode_load_texture_from_image_buffer(device, encoder, usage, img),
        ImageRgba8(img) => encode_load_texture_from_image_buffer(device, encoder, usage, img),
        ImageBgra8(img) => encode_load_texture_from_image_buffer(device, encoder, usage, img),
        ImageLuma16(img) => encode_load_texture_from_image_buffer(device, encoder, usage, img),
        ImageLumaA16(img) => encode_load_texture_from_image_buffer(device, encoder, usage, img),
        ImageRgba16(img) => encode_load_texture_from_image_buffer(device, encoder, usage, img),
        ImageRgb8(_img) => {
            let img = image.to_rgba();
            encode_load_texture_from_image_buffer(device, encoder, usage, &img)
        }
        ImageBgr8(_img) => {
            let img = image.to_bgra();
            encode_load_texture_from_image_buffer(device, encoder, usage, &img)
        }
        ImageRgb16(_img) => {
            // TODO: I think we lose some quality here - e.g. 16-bit channels down to 8-bit??.
            let img = image.to_rgba();
            encode_load_texture_from_image_buffer(device, encoder, usage, &img)
        }
    }
}
pub fn encode_load_texture_from_image ( device : & wgpu :: Device , encoder : & mut wgpu :: CommandEncoder , usage : wgpu :: TextureUsage , image : & image :: DynamicImage , ) -> wgpu :: Texture { use image :: DynamicImage :: * ; match image { ImageLuma8 ( img ) => encode_load_texture_from_image_buffer ( device , encoder , usage , img ) , ImageLumaA8 ( img ) => encode_load_texture_from_image_buffer ( device , encoder , usage , img ) , ImageRgba8 ( img ) => encode_load_texture_from_image_buffer ( device , encoder , usage , img ) , ImageBgra8 ( img ) => encode_load_texture_from_image_buffer ( device , encoder , usage , img ) , ImageLuma16 ( img ) => encode_load_texture_from_image_buffer ( device , encoder , usage , img ) , ImageLumaA16 ( img ) => encode_load_texture_from_image_buffer ( device , encoder , usage , img ) , ImageRgba16 ( img ) => encode_load_texture_from_image_buffer ( device , encoder , usage , img ) , ImageRgb8 ( _img ) => { let img = image . to_rgba ( ) ; encode_load_texture_from_image_buffer ( device , encoder , usage , & img ) } ImageBgr8 ( _img ) => { let img = image . to_bgra ( ) ; encode_load_texture_from_image_buffer ( device , encoder , usage , & img ) } ImageRgb16 ( _img ) => { // TODO: I think we lose some quality here - e.g. 16-bit channels down to 8-bit??. let img = image . to_rgba ( ) ; encode_load_texture_from_image_buffer ( device , encoder , usage , & img ) } } }
Encode the necessary commands to load a texture directly from a dynamic image.
Encode the necessary commands to load a texture directly from a dynamic image .
device
&wgpu::Device
encoder
&mut wgpu::CommandEncoder
usage
wgpu::TextureUsage
image
&image::DynamicImage
device
&wgpu::Device
encoder
&mut wgpu::CommandEncoder
usage
wgpu::TextureUsage
image
&image::DynamicImage