Skip to content

Commit

Permalink
Re-add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenzV committed Dec 1, 2024
1 parent 362eaef commit c01579b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/krilla/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ std::fs::write("../../target/example.pdf", &pdf).unwrap();
[examples]: https://github.com/LaurenzV/krilla/tree/main/examples
*/

// #![deny(missing_docs)]
#![deny(missing_docs)]

mod chunk_container;
mod graphics_state;
Expand Down
19 changes: 19 additions & 0 deletions crates/krilla/src/object/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ use zune_jpeg::JpegDecoder;
use zune_png::zune_core::colorspace::ColorSpace;
use zune_png::PngDecoder;

/// The number of buits per color component.
#[derive(Debug, Hash, Eq, PartialEq, Copy, Clone)]
pub enum BitsPerComponent {
/// Eight bits per component.
Eight,
/// Sixteen bits per component.
Sixteen,
}

Expand All @@ -40,10 +43,14 @@ impl BitsPerComponent {
}
}

/// The color space of the image.
#[derive(Debug, Hash, Eq, PartialEq, Copy, Clone)]
pub enum ImageColorspace {
/// The RGB color space.
Rgb,
/// The luma color space.
Luma,
/// The CMYK color space.
Cmyk,
}

Expand Down Expand Up @@ -100,12 +107,24 @@ impl Repr {
}
}

/// A trait for custom images, which you can use if the
/// current methods provided by krilla (JPEG/PNG/WEBP/GIF) images
/// are not suitable for your own purpose.
///
/// Note that a struct implementing this trait should be cheap to
/// hash and clone, otherwise performance might be bad!
pub trait CustomImage: Hash + Clone + Send + Sync + 'static {
/// Return the raw bytes of the color channel.
fn color_channel(&self) -> &[u8];
/// Return the raw bytes of the alpha channel, if available.
fn alpha_channel(&self) -> Option<&[u8]>;
/// Return the bits per component of the image.
fn bits_per_component(&self) -> BitsPerComponent;
/// Return the dimensions of the image.
fn size(&self) -> (u32, u32);
/// Return the ICC profile of the image, is available.
fn icc_profile(&self) -> Option<&[u8]>;
/// Return the color space of the image.
fn color_space(&self) -> ImageColorspace;
}

Expand Down

0 comments on commit c01579b

Please sign in to comment.