M4.69: Targa export at 16, 24 or 32 bits per pixel

document.export {format: "tga"} writes uncompressed true-colour Targa files
through the raster export path (resolution, background, anti-aliasing,
artboard ranges): depth 16 (5-5-5 with a one-bit alpha), 24 (flattened on
white) or 32 (8-bit alpha), rows bottom-up, with the version 2 footer.
Export As offers it with the tgaOptions dialog (Depth).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bflatastic
2026-10-05 15:24:51 +07:00
co-authored by Claude Opus 5.5
parent f2fc8782c7
commit b578c32f4d
16 changed files with 224 additions and 26 deletions
+8
View File
@@ -9,6 +9,7 @@ pub mod gif;
pub mod jpeg;
pub mod png;
pub mod quantize;
pub mod tga;
pub mod tiff;
use vectorcraft_doc::{Document, Node, NodeKind};
@@ -27,6 +28,7 @@ pub enum RasterFormat {
Gif,
Tiff,
Bmp,
Tga,
}
/// How a raster export renders and encodes.
@@ -49,6 +51,8 @@ pub struct RasterExportOptions {
pub tiff: tiff::TiffOptions,
/// BMP layout, depth, compression and row order.
pub bmp: bmp::BmpOptions,
/// Targa depth.
pub tga: tga::TgaOptions,
}
impl Default for RasterExportOptions {
@@ -63,6 +67,7 @@ impl Default for RasterExportOptions {
palette: quantize::PaletteOptions::default(),
tiff: tiff::TiffOptions::default(),
bmp: bmp::BmpOptions::default(),
tga: tga::TgaOptions::default(),
}
}
}
@@ -109,6 +114,7 @@ impl RasterExportOptions {
}
RasterFormat::Tiff => tiff::encode(img, self.ppi, &self.tiff),
RasterFormat::Bmp => bmp::encode(&img.to_straight(), img.width, img.height, self.ppi, &self.bmp, &self.palette),
RasterFormat::Tga => tga::encode(&img.to_straight(), img.width, img.height, &self.tga),
}
}
@@ -191,4 +197,6 @@ mod tests_jpeg;
#[cfg(test)]
mod tests_palette;
#[cfg(test)]
mod tests_tga;
#[cfg(test)]
mod tests_tiff;