pub fn encode(
pixels: &[u8],
width: u32,
height: u32,
num_components: u16,
bit_depth: u8,
signed: bool,
options: &EncodeOptions,
) -> EncodeResult<Vec<u8>>Expand description
Encode pixel data into a JPEG 2000 codestream.
§Arguments
pixels— Raw pixel data. For 8-bit: one byte per sample. For >8-bit: two bytes per sample (little-endian u16).width— Image width in pixels.height— Image height in pixels.num_components— Number of components (1 for grayscale, 3 for RGB).bit_depth— Bits per sample (e.g., 8, 12, 16).signed— Whether samples are signed.options— Encoding parameters.
§Returns
The encoded JPEG 2000 codestream bytes (.j2c format).
§Errors
Returns an error when dimensions, sample data, component metadata, or encoding options are invalid, or when a codec stage cannot encode them.