pub struct Image { /* private fields */ }Expand description
图像 — 对齐 PHP Grafika\Gd\Image
PHP Image 类持有 GD 资源 + 元数据(width/height/type/file_path/animated/blocks)。
Rust 端用 DynamicImage 替代 GD 资源,其余字段保留。
Implementations§
Source§impl Image
impl Image
Sourcepub fn open<P>(path: P) -> Result<Image, ImageError>
pub fn open<P>(path: P) -> Result<Image, ImageError>
从文件打开 — 对齐 Image::createFromFile($imageFile)
PHP 行为:用 getimagesize() 探测类型,分派到 _createGif/_createJpeg/_createPng/_createWbmp。
Rust 端用 image::open 统一处理,再用 guess_type 推断类型。
Sourcepub fn create_blank(width: u32, height: u32) -> Image
pub fn create_blank(width: u32, height: u32) -> Image
创建空白画布 — 对齐 Image::createBlank($width, $height)
PHP 行为:imagecreatetruecolor($width, $height),默认黑色。
Rust 端用 RgbaImage::new,默认透明(与 PHP GD 默认黑色不同,但更符合 Rust 习惯)。
Sourcepub fn from_dynamic(dyn_image: DynamicImage, image_type: ImageType) -> Image
pub fn from_dynamic(dyn_image: DynamicImage, image_type: ImageType) -> Image
从 DynamicImage 构造(Rust 扩展,无 PHP 对应)
Sourcepub fn image_type(&self) -> ImageType
pub fn image_type(&self) -> ImageType
获取图像类型 — 对齐 Image::getType()
Sourcepub fn as_dynamic(&self) -> &DynamicImage
pub fn as_dynamic(&self) -> &DynamicImage
获取内部 DynamicImage 引用(Rust 扩展)
Sourcepub fn as_dynamic_mut(&mut self) -> &mut DynamicImage
pub fn as_dynamic_mut(&mut self) -> &mut DynamicImage
获取内部 DynamicImage 可变引用(Rust 扩展)
Sourcepub fn to_rgba8(&self) -> ImageBuffer<Rgba<u8>, Vec<u8>>
pub fn to_rgba8(&self) -> ImageBuffer<Rgba<u8>, Vec<u8>>
转换为 RGBA8 — 用于图像操作(Rust 扩展,对齐 GD imagecreatetruecolor 返回的资源)
Sourcepub fn from_rgba8(
image: ImageBuffer<Rgba<u8>, Vec<u8>>,
image_type: ImageType,
) -> Image
pub fn from_rgba8( image: ImageBuffer<Rgba<u8>, Vec<u8>>, image_type: ImageType, ) -> Image
从 RGBA8 缓冲构造(Rust 扩展)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Image
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnsafeUnpin for Image
impl UnwindSafe for Image
Blanket Implementations§
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.