Comments (6)
The API could use DynamicImage::write_with_encoder
. Analogous to how you can control compression parameters for JPEG:
let encoder = JpegEncoder::new_with_quality(&mut writer, 95);
img.write_with_encoder(encoder)?;
That said, TGA compression is not great by modern standards. If you can use a different format, you'll likely get better compression
from image.
That said, TGA compression is not great by modern standards. If you can use a different format, you'll likely get better compression
It's not my choice, unfortunately ๐
The API could use DynamicImage::write_with_encoder
So a possible API could be:
pub struct TgaEncoder<W: Write> {
writer: W,
use_rle: bool,
}
impl<W: Write> for TgaEncoder<W> {
// ... new
pub fn with_rle(w: W) -> TgaEncoder<W> {
TgaEncoder {
writer: w,
use_rle: true,
}
}
pub fn use_rle(mut self) -> TgaEncoder<W> {
self.use_rle = true;
self
}
}
let encoder = TgaEncoder::with_rle(&mut writer);
// or
let encoder = TgaEncoder::new(&mut writer).use_rle();
img.write_with_encoder(encoder);
from image.
Yeah. Though, I'd probably suggest calling it "rle" or "compression" or something like that. Even the uncompressed version still counts as "encoding".
Another question is whether it makes more sense to add the new option as a constructor ("with_rle") or as a setter ("set_rle"). I think the existing encoders all use constructors, but that doesn't seem as sustainable if we add more options...
from image.
Yeah. Though, I'd probably suggest calling it "rle" or "compression" or something like that. Even the uncompressed version still counts as "encoding".
Another question is whether it makes more sense to add the new option as a constructor ("with_rle") or as a setter ("set_rle"). I think the existing encoders all use constructors, but that doesn't seem as sustainable if we add more options...
Updated ๐
from image.
I'm trying to read a bit into the code, and just documenting my thoughts.
Looks like tga::Header::from_pixel_data
would need another parameter use_rle
, and extend the match from:
match color_type {
ColorType::Rgba8 => (8, 24, ImageType::RawTrueColor),
// ...
}
to
match (color_type, use_rle) {
(ColorType::Rgba8, false) => (8, 24, ImageType::RawTrueColor),
(ColorType::Rgba8, true) => (8, 24, ImageType::RunTrueColor),
// ... etc
}
Need to check the spec to see if this is the only change required for header.rs
.
from image.
Here's my first pass for TGA RLE support:
from image.
Related Issues (20)
- Add in-place versions of all rotation operations HOT 1
- `DynamicImage::crop()` is slow because `to_image()` is slow HOT 1
- Cropping API doesn't check bounds, easy to misuse HOT 7
- EnumeratePixels and EnumerateRows should implement DoubleEndedIterator HOT 3
- Implement a `rows()` iterator on `SubImage` HOT 6
- how to convert a rgbaImage to opencv's Mat?
- Regression: Hot lib reload, unable to find __rust_alloc. HOT 6
- Increased generation loss in JPEG encoder HOT 1
- Broken link in docs HOT 2
- Should the next major release be 1.0? HOT 2
- Detect alpha on jpeg HOT 2
- Alternate versions of the crates which allow regular breaking changes HOT 7
- Animated WebP decoding error HOT 8
- โCorrupt RLE dataโ on simple BMP
- Make set_icc_profile function accessible
- Blur for images with alpha is incorrect, bleeds color from transparent pixels HOT 4
- Not reproducible crash in png module
- Error: PNG image and JPEG failed loading
- Calling `resize` returns a `ImageBuffer <Rgba<_>, _>` for `DynamicImage` HOT 1
- updating from image v0.24 to image v0.25 is causing colour distortions HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from image.