pub struct ImageBlp {Show 15 fields
pub version: Version,
pub texture_type: TextureType,
pub compression: u8,
pub alpha_bits: u32,
pub alpha_type: u8,
pub has_mips: u8,
pub width: u32,
pub height: u32,
pub extra: u32,
pub has_mipmaps: u32,
pub mipmaps: Vec<Mipmap>,
pub holes: usize,
pub header_offset: usize,
pub header_length: usize,
pub source: SourceKind,
}Fields§
§version: Version§texture_type: TextureType§compression: u8§alpha_bits: u32§alpha_type: u8§has_mips: u8§width: u32§height: u32§extra: u32§has_mipmaps: u32§mipmaps: Vec<Mipmap>§holes: usize§header_offset: usize§header_length: usize§source: SourceKindImplementations§
Source§impl ImageBlp
impl ImageBlp
Source§impl ImageBlp
impl ImageBlp
Sourcepub fn from_buf_image(buf: &[u8]) -> Result<Self, BlpError>
pub fn from_buf_image(buf: &[u8]) -> Result<Self, BlpError>
Lightweight path for “arbitrary image”: layout only without RGBA. Supports both regular image formats (via image library), and Adobe Photoshop (PSD) files with automatic signature detection.
- Read source dimensions (without full decoding)
- Choose target frame (W*,H*) — powers of two by “minimum upscale” and “minimum crop” rule
- Form mipmap chain (only width/height), image=None Tail after 1×1 filled with 0×0 (not 1×1).
Source§impl ImageBlp
impl ImageBlp
Sourcepub fn decode_direct(
&mut self,
buf: &[u8],
mip_visible: &[bool],
) -> Result<(), BlpError>
pub fn decode_direct( &mut self, buf: &[u8], mip_visible: &[bool], ) -> Result<(), BlpError>
DIRECT (paletted) decoding.
Reads palette from the header area and, for each mipmap, reads indices + alpha, then reconstructs RGBA images.
mip_visible[i] == false→ skip decoding for that mipmap (image staysNone).- If
mip_visiblehas no entry for indexi, we treat it astrue.
Source§impl ImageBlp
impl ImageBlp
Sourcepub fn decode_jpeg(
&mut self,
buf: &[u8],
mip_visible: &[bool],
) -> Result<(), BlpError>
pub fn decode_jpeg( &mut self, buf: &[u8], mip_visible: &[bool], ) -> Result<(), BlpError>
JPEG path:
- Takes a shared JPEG header from
[header_offset .. header_offset+header_length). - For each mip, concatenates
[header][tail]→ full JPEG, then decodes it. - Respects
mip_visible: ifmip_visible[i] == false, the mip is skipped (image staysNone). Missing indices inmip_visibleare treated astrue.
Source§impl ImageBlp
impl ImageBlp
Sourcepub fn decode_image(
&mut self,
buf: &[u8],
mip_visible: &[bool],
) -> Result<(), BlpError>
pub fn decode_image( &mut self, buf: &[u8], mip_visible: &[bool], ) -> Result<(), BlpError>
External image path:
- Scale-to-cover without aspect distortion to (target_w, target_h).
- Center-crop to exactly (target_w, target_h).
- Generate mip chain, honoring
mip_visibleflags:- If
mip_visible[i] == false→ we do NOT materialize pixels for mip i (image staysNone). - Missing indices in
mip_visibleare treated astrue.
- If
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ImageBlp
impl RefUnwindSafe for ImageBlp
impl Send for ImageBlp
impl Sync for ImageBlp
impl Unpin for ImageBlp
impl UnsafeUnpin for ImageBlp
impl UnwindSafe for ImageBlp
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
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
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().