ltk_texture 0.5.0

Texture decoding/encoding utilities for League Toolkit
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use byteorder::{ReadBytesExt, LE};
use std::io;

use super::{format::TextureFileFormat, ReadError, Texture};

impl Texture {
    /// Read a texture from a reader
    pub fn from_reader<R: io::Read + io::Seek + ?Sized>(reader: &mut R) -> Result<Self, ReadError> {
        let magic = reader.read_u32::<LE>()?;

        match TextureFileFormat::from_magic(magic) {
            TextureFileFormat::Unknown => Err(ReadError::UnknownTextureFormat(magic)),
            format => format.read_no_magic(reader),
        }
    }
}