@@ -570,43 +570,57 @@ impl DecodedImage {
570570 }
571571
572572 // FIXME: this assumes PixelFormat::RgbA32
573- pub ( crate ) fn apply_rgb24_bitmap (
573+ fn apply_rgb24_iter < ' a , I > (
574574 & mut self ,
575- rgb24 : & [ u8 ] ,
575+ rgb24 : I ,
576576 update_rectangle : & InclusiveRectangle ,
577- ) -> SessionResult < InclusiveRectangle > {
577+ ) -> SessionResult < InclusiveRectangle >
578+ where
579+ I : Iterator < Item = & ' a [ u8 ] > ,
580+ {
578581 const SRC_COLOR_DEPTH : usize = 3 ;
579582 const DST_COLOR_DEPTH : usize = 4 ;
580583
581584 let image_width = self . width as usize ;
582- let rectangle_width = usize:: from ( update_rectangle. width ( ) ) ;
583585 let top = usize:: from ( update_rectangle. top ) ;
584586 let left = usize:: from ( update_rectangle. left ) ;
585587
586588 let pointer_rendering_state = self . pointer_rendering_begin ( update_rectangle) ?;
587589
588- rgb24
589- . chunks_exact ( rectangle_width * SRC_COLOR_DEPTH )
590- . rev ( )
591- . enumerate ( )
592- . for_each ( |( row_idx, row) | {
593- row. chunks_exact ( SRC_COLOR_DEPTH )
594- . enumerate ( )
595- . for_each ( |( col_idx, src_pixel) | {
596- let dst_idx = ( ( top + row_idx) * image_width + left + col_idx) * DST_COLOR_DEPTH ;
590+ rgb24. enumerate ( ) . for_each ( |( row_idx, row) | {
591+ row. chunks_exact ( SRC_COLOR_DEPTH )
592+ . enumerate ( )
593+ . for_each ( |( col_idx, src_pixel) | {
594+ let dst_idx = ( ( top + row_idx) * image_width + left + col_idx) * DST_COLOR_DEPTH ;
597595
598- // Copy RGB channels as is
599- self . data [ dst_idx..dst_idx + SRC_COLOR_DEPTH ] . copy_from_slice ( src_pixel) ;
600- // Set alpha channel to opaque(0xFF)
601- self . data [ dst_idx + 3 ] = 0xFF ;
602- } )
603- } ) ;
596+ // Copy RGB channels as is
597+ self . data [ dst_idx..dst_idx + SRC_COLOR_DEPTH ] . copy_from_slice ( src_pixel) ;
598+ // Set alpha channel to opaque(0xFF)
599+ self . data [ dst_idx + 3 ] = 0xFF ;
600+ } )
601+ } ) ;
604602
605603 let update_rectangle = self . pointer_rendering_end ( pointer_rendering_state) ?;
606604
607605 Ok ( update_rectangle)
608606 }
609607
608+ pub ( crate ) fn apply_rgb24 (
609+ & mut self ,
610+ rgb24 : & [ u8 ] ,
611+ update_rectangle : & InclusiveRectangle ,
612+ flip : bool ,
613+ ) -> SessionResult < InclusiveRectangle > {
614+ const SRC_COLOR_DEPTH : usize = 3 ;
615+ let rectangle_width = usize:: from ( update_rectangle. width ( ) ) ;
616+ let lines = rgb24. chunks_exact ( rectangle_width * SRC_COLOR_DEPTH ) ;
617+ if flip {
618+ self . apply_rgb24_iter ( lines. rev ( ) , update_rectangle)
619+ } else {
620+ self . apply_rgb24_iter ( lines, update_rectangle)
621+ }
622+ }
623+
610624 // FIXME: this assumes PixelFormat::RgbA32
611625 pub ( crate ) fn apply_rgb32_bitmap (
612626 & mut self ,
0 commit comments