pub fn convert_image(
        source: &[u8],
        width: u32,
        height: u32,
        source_format: ImageFormat,
        dest_format: ImageFormat,
    ) -> Result<Vec<u8>> {
        let source_size = VtfFile::compute_image_size(width, height, 1, 1, source_format) as usize;
        let target_size = VtfFile::compute_image_size(width, height, 1, 1, dest_format) as usize;
        if source.len() < source_size {
            return Err(Error::InvalidLength);
        }
        let mut buf = Vec::with_capacity(target_size);
        unsafe {
            ffi_try!(ffi::vlImageConvert(
                source.as_ptr() as *mut u8,
                buf.as_mut_ptr(),
                width,
                height,
                source_format as i32,
                dest_format as i32
            ));
            buf.set_len(target_size);
        }
        Ok(buf)
    }
/// Convert between supported image formats.
///
/// # Errors
///
/// Returns `Err` if `source` has invalid length or if the conversion fails.
Convert between supported image formats.
Convert between supported image formats .
pub fn convert_image(
        source: &[u8],
        width: u32,
        height: u32,
        source_format: ImageFormat,
        dest_format: ImageFormat,
    ) -> Result<Vec<u8>> {
        let source_size = VtfFile::compute_image_size(width, height, 1, 1, source_format) as usize;
        let target_size = VtfFile::compute_image_size(width, height, 1, 1, dest_format) as usize;
        if source.len() < source_size {
            return Err(Error::InvalidLength);
        }
        let mut buf = Vec::with_capacity(target_size);
        unsafe {
            ffi_try!(ffi::vlImageConvert(
                source.as_ptr() as *mut u8,
                buf.as_mut_ptr(),
                width,
                height,
                source_format as i32,
                dest_format as i32
            ));
            buf.set_len(target_size);
        }
        Ok(buf)
    }
pub fn convert_image ( source : & [ u8 ] , width : u32 , height : u32 , source_format : ImageFormat , dest_format : ImageFormat , ) -> Result < Vec < u8 > > { let source_size = VtfFile :: compute_image_size ( width , height , 1 , 1 , source_format ) as usize ; let target_size = VtfFile :: compute_image_size ( width , height , 1 , 1 , dest_format ) as usize ; if source . len ( ) < source_size { return Err ( Error :: InvalidLength ) ; } let mut buf = Vec :: with_capacity ( target_size ) ; unsafe { ffi_try ! ( ffi vlImageConvert ( source as_ptr ( ) as mut u8 buf as_mut_ptr ( ) width height source_format as i32 dest_format as i32 ) ) ; buf . set_len ( target_size ) ; } Ok ( buf ) }
Convert between supported image formats.
Convert between supported image formats .
source
&[u8]
width
u32
height
u32
source_format
ImageFormat
dest_format
ImageFormat
source
&[u8]
width
u32
height
u32
source_format
ImageFormat
dest_format
ImageFormat
errors
Returns `Err` if `source` has invalid length or if the conversion fails.
Returns ` Err ` if ` source ` has invalid length or if the conversion fails .