pub fn load_file<P: AsRef<Path>>(&mut self, path: P) -> Result<(), TextureError> {
        let path = path.as_ref();
        let RawImageData { info, buf } = RawImageData::from_file(path)?;
        let texture_format = match (info.color_type, info.bit_depth) {
            (png::ColorType::RGBA, png::BitDepth::Eight) => TextureFormat::RGBA_8,
            (png::ColorType::RGB, png::BitDepth::Eight)  => TextureFormat::RGB_8,
            other => {
                let message = format!(
                    "Unsuported texture format ({:?}, {:?}) in \"{}\" ({}:{})",
                    other.0, other.1,
                    path.to_string_lossy(),
                    file!(), line!()
                );

                return Err(TextureError { 
                    source: Some(path.to_string_lossy().into()),
                    error: io::Error::new(io::ErrorKind::Other, message) 
                });
            }
        };
        self.load_data(&buf, info.width, info.height, texture_format);
        Ok(())
    }
/// Attempts to load data from the given image file into this texture. Note that
/// it is usually more convenient to create a new texture directly from a file using
/// [`from_file(path)`](struct.Texture.html#method.from_file).
///
/// # Example
/// ```rust,no_run
/// use gondola::texture::Texture;
///
/// let mut texture = Texture::new();
/// texture.load_file("assets/test.png").expect("Failed to load texture");
/// ```
Attempts to load data from the given image file into this texture. Note that
it is usually more convenient to create a new texture directly from a file using
[`from_file(path)`](struct.Texture.html#method.from_file).
Attempts to load data from the given image file into this texture . Note that it is usually more convenient to create a new texture directly from a file using [ ` from_file ( path ) ` ] ( struct . Texture . html#method . from_file ) .
pub fn load_file<P: AsRef<Path>>(&mut self, path: P) -> Result<(), TextureError> {
        let path = path.as_ref();
        let RawImageData { info, buf } = RawImageData::from_file(path)?;
        let texture_format = match (info.color_type, info.bit_depth) {
            (png::ColorType::RGBA, png::BitDepth::Eight) => TextureFormat::RGBA_8,
            (png::ColorType::RGB, png::BitDepth::Eight)  => TextureFormat::RGB_8,
            other => {
                let message = format!(
                    "Unsuported texture format ({:?}, {:?}) in \"{}\" ({}:{})",
                    other.0, other.1,
                    path.to_string_lossy(),
                    file!(), line!()
                );
                return Err(TextureError { 
                    source: Some(path.to_string_lossy().into()),
                    error: io::Error::new(io::ErrorKind::Other, message) 
                });
            }
        };
        self.load_data(&buf, info.width, info.height, texture_format);
        Ok(())
    }
pub fn load_file < P : AsRef < Path > > ( & mut self , path : P ) -> Result < ( ) , TextureError > { let path = path . as_ref ( ) ; let RawImageData { info , buf } = RawImageData :: from_file ( path ) ? ; let texture_format = match ( info . color_type , info . bit_depth ) { ( png :: ColorType :: RGBA , png :: BitDepth :: Eight ) => TextureFormat :: RGBA_8 , ( png :: ColorType :: RGB , png :: BitDepth :: Eight ) => TextureFormat :: RGB_8 , other => { let message = format ! ( " \" \" " other 0 other 1 path to_string_lossy ( ) file ( ) line ( ) ) ; return Err ( TextureError { source : Some ( path . to_string_lossy ( ) . into ( ) ) , error : io :: Error :: new ( io :: ErrorKind :: Other , message ) } ) ; } } ; self . load_data ( & buf , info . width , info . height , texture_format ) ; Ok ( ( ) ) }
Attempts to load data from the given image file into this texture.
Attempts to load data from the given image file into this texture .
&mut self
path
P
&mut self
path
P
example
```rust,no_run
use gondola::texture::Texture.

let mut texture = Texture::new();
texture.load_file("assets/test.png").expect("Failed to load texture");
```
` ` ` rust no_run use gondola :: texture :: Texture . let mut texture = Texture :: new () ; texture . load_file ( " assets / test . png " ) . expect ( " Failed to load texture " ) ; ` ` `