1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//#![no_std]
#![allow(unused)]
#![allow(bad_style)]
#![allow(dead_code)]
#![allow(clippy::match_ref_pats)]
#![allow(clippy::unreadable_literal)]
#![allow(clippy::naive_bytecount)]
#![allow(clippy::single_match)]
#![allow(clippy::cognitive_complexity)]
#![allow(clippy::redundant_closure_call)]
//#![warn(missing_docs)]

//! Image file format parsing library.

extern crate alloc;
use alloc::{borrow::Cow, format, string::String, vec, vec::Vec};

use bytemuck::*;

use core::{
  convert::{TryFrom, TryInto},
  mem::{align_of, size_of, size_of_val},
  ops::{Index, IndexMut},
};

/// Dumps out some bindings to the console.
///
/// * With literal first, uses that as the format string for all bindings to be
///   formatted.
/// * Otherwise it uses `"{:?}"`
macro_rules! dump {
  ($fmt_str:literal, $($n:expr),*) => (if cfg!(debug_assertions) {
    $(println!(
      concat!("{}:{}> ", stringify!($n), ": ", $fmt_str),
      file!(),
      line!(),
      $n);
    )*
  });
  ($($n:expr),*) => (if cfg!(debug_assertions) {
    $(println!(
      concat!("{}:{}> ",stringify!($n),": {:?}"),
      file!(),
      line!(),
      $n);
    )*
  });
}

/// Prints out a message, intended for tracing.
///
/// * With just a literal, prints that message.
/// * With a literal and tokens, uses it as a format string to format the
///   tokens.
macro_rules! trace {
  ($msg:literal) => (if cfg!(debug_assertions) {
    println!(
      concat!("{}:{}> ",$msg),
      file!(),
      line!(),
    );
  });
  ($fmt_str:literal, $($tokens:tt)*) => (if cfg!(debug_assertions) {
    println!(
      concat!("{}:{}> ",$fmt_str),
      file!(),
      line!(),
      $($tokens)*
    );
  });
}

pub mod pixel_formats;
pub use pixel_formats::*;

pub mod bitmaps;
pub use bitmaps::*;

#[cfg(feature = "png")]
pub mod png;