convert_ref

Function convert_ref 

Source
pub fn convert_ref<SRC, DEST>(
    source: &dyn HasRowChunksExact<SRC>,
) -> Result<impl HasRowChunksExact<DEST> + '_, Error>
where SRC: PixelFormat, DEST: PixelFormat,
Expand description

Convert input image, a reference to a trait object implementing HasRowChunksExact<SRC>, into an output implementing HasRowChunksExact<DEST>.

The output will borrow from the source if no format change is required, otherwise a newly allocated image will be returned.

This is a general purpose function which should be able to convert between many types as efficiently as possible. In case no data needs to be copied, no data will be copied.

For a version which converts into a pre-allocated buffer, use convert_into (which will copy the image even if the format remains unchanged).