mod jpeg;
mod raw;
use pdfrum_object::ObjRef;
use crate::doc::EditDoc;
use crate::error::Error;
pub use raw::PixelFormat;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct EmbeddedImage {
image: ObjRef,
width: u32,
height: u32,
}
impl EmbeddedImage {
#[must_use]
pub fn object(&self) -> ObjRef {
self.image
}
#[must_use]
pub fn width(&self) -> u32 {
self.width
}
#[must_use]
pub fn height(&self) -> u32 {
self.height
}
}
impl EditDoc<'_> {
pub fn embed_jpeg(&mut self, bytes: &[u8]) -> Result<EmbeddedImage, Error> {
jpeg::embed(self, bytes)
}
pub fn embed_image(
&mut self,
pixels: &[u8],
width: u32,
height: u32,
format: PixelFormat,
) -> Result<EmbeddedImage, Error> {
raw::embed(self, pixels, width, height, format)
}
}