Struct PnmEncoder
struct PnmEncoder<W: Write> { ... }
Encodes images to any of the pnm image formats.
Implementations
impl<W: Write> PnmEncoder<W>
fn new(writer: W) -> SelfCreate new
PnmEncoderfrom thewriter.The encoded images will have some
pnmformat. If more control over the image type is required, use either one ofwith_subtypeorwith_header. For more information on the behaviour, seewith_dynamic_header.fn with_subtype(self: Self, subtype: PnmSubtype) -> SelfEncode a specific pnm subtype image.
The magic number and encoding type will be chosen as provided while the rest of the header data will be generated dynamically. Trying to encode incompatible images (e.g. encoding an RGB image as Graymap) will result in an error.
This will overwrite the effect of earlier calls to
with_headerandwith_dynamic_header.fn with_header(self: Self, header: PnmHeader) -> SelfEnforce the use of a chosen header.
While this option gives the most control over the actual written data, the encoding process will error in case the header data and image parameters do not agree. It is the users obligation to ensure that the width and height are set accordingly, for example.
Choose this option if you want a lossless decoding/encoding round trip.
This will overwrite the effect of earlier calls to
with_subtypeandwith_dynamic_header.fn with_dynamic_header(self: Self) -> SelfCreate the header dynamically for each image.
This is the default option upon creation of the encoder. With this, most images should be encodable but the specific format chosen is out of the users control. The pnm subtype is chosen arbitrarily by the library.
This will overwrite the effect of earlier calls to
with_subtypeandwith_header.fn encode<'s, S>(self: &mut Self, image: S, width: u32, height: u32, color: ExtendedColorType) -> ImageResult<()> where S: Into<FlatSamples<'s>>Encode an image whose samples are represented as
u8.Some
pnmsubtypes are incompatible with some color options, a chosen header most certainly with any deviation from the original decoded image.
impl<T> Any for PnmEncoder<W>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for PnmEncoder<W>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for PnmEncoder<W>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for PnmEncoder<W>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Pointable for PnmEncoder<W>
unsafe fn init(init: <T as Pointable>::Init) -> usizeunsafe fn deref<'a>(ptr: usize) -> &'a Tunsafe fn deref_mut<'a>(ptr: usize) -> &'a mut Tunsafe fn drop(ptr: usize)
impl<T, U> Into for PnmEncoder<W>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for PnmEncoder<W>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for PnmEncoder<W>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>
impl<W> Freeze for PnmEncoder<W>
impl<W> RefUnwindSafe for PnmEncoder<W>
impl<W> Send for PnmEncoder<W>
impl<W> Sync for PnmEncoder<W>
impl<W> Unpin for PnmEncoder<W>
impl<W> UnsafeUnpin for PnmEncoder<W>
impl<W> UnwindSafe for PnmEncoder<W>
impl<W: Write> ImageEncoder for PnmEncoder<W>
fn write_image(self: Self, buf: &[u8], width: u32, height: u32, color_type: ExtendedColorType) -> ImageResult<()>