Crates.io | serialimagedata |
lib.rs | serialimagedata |
version | 1.0.0 |
source | src |
created_at | 2023-10-03 20:37:35.400775 |
updated_at | 2023-10-03 20:37:35.400775 |
description | Serialization for the [image](https://crates.io/crates/image) crate's DynamicImage type, with additional metadata. |
homepage | https://crates.io/crates/serialimagedata |
repository | https://github.com/sunipkm/serialimagedata |
max_upload_size | |
id | 991525 |
size | 31,979 |
A SerialImageData
object encapsulates the generic image types defined in the image
crate, along with any metadata, in order to obtain a portable, pixel format independent image that is serializable.
Add the following to your Cargo.toml
:
[dependencies]
serialimageadata = "1.0.0"
and the following to your source code:
use serialimageadata::{ImageMetaData, SerialImageData, SerialImagePixel, SerialImageStorageTypes};
Then, you can create a new image metadata object:
let meta = ImageMetaData::new(...);
Then, a SerialImageData
structure can be created from a vector buffer. For example, if the buffer imgdata
has 8-bit RGB values and its width and height are known,
let img = SerialImageData::new(meta, imgdata, width, height, SerialImagePixel::U8(3)); // Indicate that the data storage is backed by u8 data, with 3 elements per pixel.
SerialImageData
implements the TryFrom
and TryInto
traits for DynamicImage
.