pub struct ImageData { /* private fields */ }Expand description
从 PDF 中识别的图片信息。
bytes 为 None 时表示仅存在引用(未提取原始数据)。
§Examples
use easypdf_core::{ImageData, ImageFormat};
let data = ImageData::new(ImageFormat::Png)
.with_caption("Logo")
.with_dimensions(200.0, 100.0);
assert_eq!(data.format(), ImageFormat::Png);
assert_eq!(data.width_pt(), Some(200.0));Implementations§
Source§impl ImageData
impl ImageData
Sourcepub const fn new(format: ImageFormat) -> Self
pub const fn new(format: ImageFormat) -> Self
创建指定格式的图片数据。
Sourcepub fn with_bytes(self, bytes: Vec<u8>) -> Self
pub fn with_bytes(self, bytes: Vec<u8>) -> Self
设置原始字节。
Sourcepub fn with_caption(self, caption: impl Into<String>) -> Self
pub fn with_caption(self, caption: impl Into<String>) -> Self
设置标题。
Sourcepub fn with_alt_text(self, alt: impl Into<String>) -> Self
pub fn with_alt_text(self, alt: impl Into<String>) -> Self
设置替代文本。
Sourcepub const fn with_dimensions(self, width_pt: f64, height_pt: f64) -> Self
pub const fn with_dimensions(self, width_pt: f64, height_pt: f64) -> Self
设置图片尺寸(PDF points)。
Sourcepub const fn format(&self) -> ImageFormat
pub const fn format(&self) -> ImageFormat
返回图片格式。
Trait Implementations§
impl StructuralPartialEq for ImageData
Auto Trait Implementations§
impl Freeze for ImageData
impl RefUnwindSafe for ImageData
impl Send for ImageData
impl Sync for ImageData
impl Unpin for ImageData
impl UnsafeUnpin for ImageData
impl UnwindSafe for ImageData
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more