@@ -761,8 +761,8 @@ macro_rules! op_chunk {
761
761
762
762
macro_rules! op_inter {
763
763
( $func: ident, $data: expr) => {
764
- $data. chunks_exact_mut( 3 ) . for_each( |pixel| {
765
- let pixel: & mut [ T ; 3 ] = pixel. try_into( ) . unwrap( ) ;
764
+ $data. chunks_exact_mut( N ) . for_each( |pixel| {
765
+ let pixel: & mut [ T ; N ] = pixel. try_into( ) . unwrap( ) ;
766
766
$func( pixel) ;
767
767
} )
768
768
} ;
@@ -821,23 +821,32 @@ macro_rules! graph {
821
821
822
822
/// Runs conversion functions to convert `pixel` from one `Space` to another
823
823
/// in the least possible moves.
824
- pub fn convert_space < T : DType > ( from : Space , to : Space , pixel : & mut [ T ; 3 ] ) {
824
+ pub fn convert_space < T : DType , const N : usize > ( from : Space , to : Space , pixel : & mut [ T ; N ] )
825
+ where
826
+ Channels < N > : ValidChannels ,
827
+ {
825
828
graph ! ( convert_space, pixel, from, to, op_single) ;
826
829
}
827
830
828
831
/// Runs conversion functions to convert `pixel` from one `Space` to another
829
832
/// in the least possible moves.
830
833
///
831
834
/// Caches conversion graph for faster iteration.
832
- pub fn convert_space_chunked < T : DType > ( from : Space , to : Space , pixels : & mut [ [ T ; 3 ] ] ) {
835
+ pub fn convert_space_chunked < T : DType , const N : usize > ( from : Space , to : Space , pixels : & mut [ [ T ; N ] ] )
836
+ where
837
+ Channels < N > : ValidChannels ,
838
+ {
833
839
graph ! ( convert_space_chunked, pixels, from, to, op_chunk) ;
834
840
}
835
841
836
842
/// Runs conversion functions to convert `pixel` from one `Space` to another
837
843
/// in the least possible moves.
838
844
///
839
845
/// Caches conversion graph for faster iteration and ignores remainder values in slice.
840
- pub fn convert_space_sliced < T : DType > ( from : Space , to : Space , pixels : & mut [ T ] ) {
846
+ pub fn convert_space_sliced < T : DType , const N : usize > ( from : Space , to : Space , pixels : & mut [ T ] )
847
+ where
848
+ Channels < N > : ValidChannels ,
849
+ {
841
850
graph ! ( convert_space_sliced, pixels, from, to, op_inter) ;
842
851
}
843
852
@@ -885,15 +894,10 @@ pub extern "C" fn convert_space_ffi(from: *const c_char, to: *const c_char, pixe
885
894
core:: slice:: from_raw_parts_mut ( pixels, len)
886
895
}
887
896
} ;
888
- convert_space_sliced ( from, to, pixels) ;
897
+ convert_space_sliced :: < _ , 3 > ( from, to, pixels) ;
889
898
0
890
899
}
891
900
892
- /// Same as `convert_space`, ignores the 4th value in `pixel`.
893
- pub fn convert_space_alpha ( from : Space , to : Space , pixel : & mut [ f32 ; 4 ] ) {
894
- unsafe { convert_space ( from, to, pixel. get_unchecked_mut ( 0 ..3 ) . try_into ( ) . unwrap_unchecked ( ) ) }
895
- }
896
-
897
901
// ### Convert Space ### }}}
898
902
899
903
// ### Str2Col ### {{{
0 commit comments