fovea-io
fovea-io adds feature-gated PNG, JPEG, and BMP codecs for fovea images.
[]
= "0.1.1"
= { = "0.1.1", = ["png"] }
Features
Each codec is behind its own Cargo feature flag. No codecs are enabled by default.
| Feature | Codecs enabled | Dependencies |
|---|---|---|
png |
PNG decode + encode | png |
jpeg |
JPEG decode + encode | jpeg-decoder, jpeg-encoder |
bmp |
BMP decode + encode | none beyond fovea-io |
all-codecs |
PNG, JPEG, and BMP | all optional codec dependencies |
Enable features in your Cargo.toml:
[]
= { = "0.1.1", = ["jpeg"] }
# or enable everything:
# fovea-io = { version = "0.1.1", features = ["all-codecs"] }
Quick start
Feature-free format detection works without enabling a codec:
use ;
let png_sig = ;
assert_eq!;
With codec features enabled, decode into per-format enums whose variants carry concrete typed images:
use ;
let bytes = read.unwrap;
match load.unwrap
Codec examples
JPEG
use Image;
use Srgb8;
use ;
let bytes = read.unwrap;
let decoded = decode.unwrap;
match decoded.image
let image = fill;
let bytes = encode.unwrap;
write.unwrap;
PNG
use ;
let bytes = read.unwrap;
let decoded = decode.unwrap;
match decoded.image
BMP
use Image;
use Srgb8;
use ;
let image = fill;
let bytes = encode.unwrap;
write.unwrap;
Architecture
- Per-codec exhaustive enums — each codec defines its own output enum, such as
PngImage,JpegImage, orBmpImage, whose variants carry concreteImage<P>values. - Metadata travels with pixels — decoded structs return pixel data and format-specific metadata together.
- Feature-gated codecs — enabling one codec does not pull in the dependencies for another.
- Sealed encode traits —
PngPixel,JpegPixel, andBmpPixelmake unsupported output formats compile-time errors.
Design principle references
§N references throughout this crate refer to the numbered design principles listed in the fovea crate documentation.
Part of the fovea project
- Core crate:
fovea - Display support:
fovea-display - End-to-end demos:
fovea-examples
License
fovea-io itself is licensed under the MIT License.
When the jpeg feature is enabled, this crate depends on jpeg-encoder, which carries an additional IJG (Independent JPEG Group) license requiring this acknowledgement:
This software is based in part on the work of the Independent JPEG Group.
See THIRD-PARTY-LICENSES.txt for full license texts of dependencies and attribution requirements.