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
//! This is based on [ImgRef](https://crates.rs/crates/rgb) and [RGB](https://crates.rs/crates/rgb) crates.
//!

extern crate rgb;
extern crate imgref;
#[cfg(target_os = "macos")] #[macro_use] extern crate objc;
#[cfg(target_os = "macos")] extern crate core_foundation;
#[cfg(target_os = "macos")] extern crate core_graphics;
#[cfg(target_os = "macos")] extern crate foreign_types;

pub use rgb::RGBA8;

mod error;
pub use error::Error;
#[cfg(target_os = "macos")] mod macos;
#[cfg(target_os = "macos")] pub use macos::*;

/// On macOS returns an RGBA 8-bit bitmap in sRGB color space with premultiplied alpha.
///
/// The input is an encoded file (PNG, JPEG, etc.)
///
/// See [`ImgRef`](https://crates.rs/crates/rgb) for instructions how to use the returned bitmap.
#[cfg(not(target_os = "macos"))]
pub fn decode_image_as_rgba_premultiplied(_file_data: &[u8]) -> Result<imgref::ImgVec<RGBA8>, Error> {
    Err(Error::Unsupported)
}

#[cfg(not(target_os = "macos"))]
/// On macOS returns an RGBA 8-bit bitmap in sRGB color space with regular (non-associated) alpha.
pub fn decode_image_as_rgba(_file_data: &[u8]) -> Result<imgref::ImgVec<RGBA8>, Error> {
    Err(Error::Unsupported)
}

#[test]
fn poke() {
    let _ = decode_image_as_rgba_premultiplied(&[]);
}