Struct Ingris

Source
pub struct Ingris();
Expand description

Haupt Struct. Enthält die Funktionen zum Lesen und Schreiben der Bilder. Ingris ist ein einfaches Bildformat, das speziell für die Verwendung in Spielen entwickelt wurde. Es verwendet zur Optimierung 4 oder 8 Bit Farbtiefe und hat einen minimalen Header. Mit 4 bit (max. 16 Farben) ist die Komprimierung besser, aber die Dekodierung etwas langsamer.

§Ein Bild erstellen und speichern

let image = Image::new(FILE_VERSION, width, height, bytes);
Ingris::write(path, &image).unwrap();

§Ein Bild aus einer Datei lesen

Ingris::read(path).unwrap();

Implementations§

Source§

impl Ingris

Source

pub fn from_bytes(buffer: Vec<u8>) -> Result<Image, IngrisError>

Ließt ein komprimiertes Bild aus einem Byte-Buffer.

  • 4bit: Es wird eine etwas schnellerer Algorithmus verwendet, wenn die Anzahl der Bytes durch 4 teilbar ist indem immer ein u32 gelesen wird.
Source

pub fn read<P: AsRef<Path>>(path: P) -> Result<Image, IngrisError>

Ließt ein Bild von einer Datei.

Source

pub fn write<P: AsRef<Path>>(path: P, image: &Image) -> Result<(), IngrisError>

Schreibt ein Bild in eine Datei.

  • 4bit: Es wird eine etwas schnellerer Algorithmus verwendet, wenn die Anzahl der Bytes durch 4 teilbar ist indem immer ein u32 geschrieben wird.

Auto Trait Implementations§

§

impl Freeze for Ingris

§

impl RefUnwindSafe for Ingris

§

impl Send for Ingris

§

impl Sync for Ingris

§

impl Unpin for Ingris

§

impl UnwindSafe for Ingris

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.