Benchmark Rust against pinned C# reference (#105)
Some checks failed
API and SemVer surface / api-surface (push) Failing after 1m8s
Native code generation / deterministic (push) Failing after 2m6s
Concurrency and resource soak audit / soak (push) Failing after 12m13s
Documentation / documentation (push) Failing after 1m36s
Imaging and meshing gate / native (push) Failing after 3m2s
JPEG 2000 feature / linux (push) Successful in 2m48s
performance evidence / audit (push) Failing after 13m49s
Release platform and feature matrix / audit (push) Successful in 44s
Native Rust workspace compile / compile (push) Failing after 55s
Skia feature / linux (push) Successful in 31m13s
Dependency and supply-chain audit / audit (push) Failing after 9m13s
Release platform and feature matrix / matrix (false, linux-stable-minimal, x86_64-unknown-linux-gnu, stable) (push) Failing after 9m49s
Release platform and feature matrix / matrix (false, windows-stable-portable, x86_64-pc-windows-gnu, stable) (push) Has been cancelled
Release platform and feature matrix / matrix (true, linux-msrv-portable, x86_64-unknown-linux-gnu, 1.96.0) (push) Has been cancelled
Release platform and feature matrix / matrix (true, linux-stable-default, x86_64-unknown-linux-gnu, stable) (push) Has been cancelled
Release platform and feature matrix / matrix (true, linux-stable-features, x86_64-unknown-linux-gnu, stable) (push) Has been cancelled
Release platform and feature matrix / matrix (true, linux-stable-release-surface, x86_64-unknown-linux-gnu, stable) (push) Has been cancelled
Release platform and feature matrix / matrix (false, macos-stable-portable, x86_64-apple-darwin, stable) (push) Has been cancelled
Some checks failed
API and SemVer surface / api-surface (push) Failing after 1m8s
Native code generation / deterministic (push) Failing after 2m6s
Concurrency and resource soak audit / soak (push) Failing after 12m13s
Documentation / documentation (push) Failing after 1m36s
Imaging and meshing gate / native (push) Failing after 3m2s
JPEG 2000 feature / linux (push) Successful in 2m48s
performance evidence / audit (push) Failing after 13m49s
Release platform and feature matrix / audit (push) Successful in 44s
Native Rust workspace compile / compile (push) Failing after 55s
Skia feature / linux (push) Successful in 31m13s
Dependency and supply-chain audit / audit (push) Failing after 9m13s
Release platform and feature matrix / matrix (false, linux-stable-minimal, x86_64-unknown-linux-gnu, stable) (push) Failing after 9m49s
Release platform and feature matrix / matrix (false, windows-stable-portable, x86_64-pc-windows-gnu, stable) (push) Has been cancelled
Release platform and feature matrix / matrix (true, linux-msrv-portable, x86_64-unknown-linux-gnu, 1.96.0) (push) Has been cancelled
Release platform and feature matrix / matrix (true, linux-stable-default, x86_64-unknown-linux-gnu, stable) (push) Has been cancelled
Release platform and feature matrix / matrix (true, linux-stable-features, x86_64-unknown-linux-gnu, stable) (push) Has been cancelled
Release platform and feature matrix / matrix (true, linux-stable-release-surface, x86_64-unknown-linux-gnu, stable) (push) Has been cancelled
Release platform and feature matrix / matrix (false, macos-stable-portable, x86_64-apple-darwin, stable) (push) Has been cancelled
This commit is contained in:
@@ -11,6 +11,16 @@ type TgaPalette = (usize, Vec<[u8; 4]>);
|
||||
pub struct Targa;
|
||||
|
||||
impl Targa {
|
||||
/// Decodes an in-memory TGA or DDS payload without copying it through the
|
||||
/// compatibility stream boundary.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns a typed error for oversized, malformed, or unsupported input.
|
||||
pub fn decode_to_managed_image_with_bytes(data: &[u8]) -> Result<ManagedImage, Error> {
|
||||
decode(data)
|
||||
}
|
||||
|
||||
/// Decodes a TGA or DDS file into planar managed-image storage.
|
||||
///
|
||||
/// # Errors
|
||||
@@ -185,6 +195,15 @@ fn decode_tga(bytes: &[u8]) -> Result<ManagedImage, Error> {
|
||||
return Err(parse(18, "truncated TGA image ID"));
|
||||
}
|
||||
let palette = read_tga_palette(bytes, header, has_color_map, color_mapped, &mut position)?;
|
||||
if !rle
|
||||
&& !grayscale
|
||||
&& palette.is_none()
|
||||
&& matches!(depth, 24 | 32)
|
||||
&& header[17] & 0x30 == 0x20
|
||||
{
|
||||
decode_plain_truecolor(bytes, position, pixels, pixel_bytes, depth, &mut image)?;
|
||||
return Ok(image);
|
||||
}
|
||||
let mut decoded = 0;
|
||||
while decoded < pixels {
|
||||
let (count, repeated) = if rle {
|
||||
@@ -238,6 +257,30 @@ fn decode_tga(bytes: &[u8]) -> Result<ManagedImage, Error> {
|
||||
Ok(image)
|
||||
}
|
||||
|
||||
fn decode_plain_truecolor(
|
||||
bytes: &[u8],
|
||||
position: usize,
|
||||
pixels: usize,
|
||||
pixel_bytes: usize,
|
||||
depth: u8,
|
||||
image: &mut ManagedImage,
|
||||
) -> Result<(), Error> {
|
||||
let byte_length = pixels.checked_mul(pixel_bytes).ok_or(Error::Argument)?;
|
||||
let end = position.checked_add(byte_length).ok_or(Error::Argument)?;
|
||||
let data = bytes
|
||||
.get(position..end)
|
||||
.ok_or_else(|| parse(position, "truncated TGA pixel data"))?;
|
||||
for (target, pixel) in data.chunks_exact(pixel_bytes).enumerate() {
|
||||
image.blue[target] = pixel[0];
|
||||
image.green[target] = pixel[1];
|
||||
image.red[target] = pixel[2];
|
||||
if depth == 32 {
|
||||
image.alpha[target] = pixel[3];
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn tga_channels(
|
||||
grayscale: bool,
|
||||
color_mapped: bool,
|
||||
|
||||
Reference in New Issue
Block a user