@@ -539,33 +539,42 @@ impl Engine {
539539 pub fn draw_image (
540540 & mut self ,
541541 image : & Image ,
542- _transformation : Transformation ,
543- _pixels : & mut tiny_skia:: PixmapMut < ' _ > ,
544- _clip_mask : & mut tiny_skia:: Mask ,
545- _clip_bounds : Rectangle ,
542+ transformation : Transformation ,
543+ pixels : & mut tiny_skia:: PixmapMut < ' _ > ,
544+ clip_mask : & mut tiny_skia:: Mask ,
545+ clip_bounds : Rectangle ,
546546 ) {
547547 match image {
548548 #[ cfg( feature = "image" ) ]
549549 Image :: Raster {
550550 handle,
551551 filter_method,
552552 bounds,
553+ rotation,
554+ scale,
553555 } => {
554- let physical_bounds = * bounds * _transformation ;
556+ let physical_bounds = * bounds * transformation ;
555557
556- if !_clip_bounds . intersects ( & physical_bounds) {
558+ if !clip_bounds . intersects ( & physical_bounds) {
557559 return ;
558560 }
559561
560- let clip_mask = ( !physical_bounds. is_within ( & _clip_bounds) )
561- . then_some ( _clip_mask as & _ ) ;
562+ let clip_mask = ( !physical_bounds. is_within ( & clip_bounds) )
563+ . then_some ( clip_mask as & _ ) ;
564+
565+ let center = physical_bounds. center ( ) ;
566+ let transform = into_transform ( transformation)
567+ . post_rotate_at ( rotation. to_degrees ( ) , center. x , center. y )
568+ . post_translate ( -center. x , -center. y )
569+ . post_scale ( scale. width , scale. height )
570+ . post_translate ( center. x , center. y ) ;
562571
563572 self . raster_pipeline . draw (
564573 handle,
565574 * filter_method,
566575 * bounds,
567- _pixels ,
568- into_transform ( _transformation ) ,
576+ pixels ,
577+ transform ,
569578 clip_mask,
570579 ) ;
571580 }
@@ -574,21 +583,31 @@ impl Engine {
574583 handle,
575584 color,
576585 bounds,
586+ rotation,
587+ scale,
577588 } => {
578- let physical_bounds = * bounds * _transformation ;
589+ let physical_bounds = * bounds * transformation ;
579590
580- if !_clip_bounds . intersects ( & physical_bounds) {
591+ if !clip_bounds . intersects ( & physical_bounds) {
581592 return ;
582593 }
583594
584- let clip_mask = ( !physical_bounds. is_within ( & _clip_bounds) )
585- . then_some ( _clip_mask as & _ ) ;
595+ let clip_mask = ( !physical_bounds. is_within ( & clip_bounds) )
596+ . then_some ( clip_mask as & _ ) ;
597+
598+ let center = physical_bounds. center ( ) ;
599+ let transform = into_transform ( transformation)
600+ . post_rotate_at ( rotation. to_degrees ( ) , center. x , center. y )
601+ . post_translate ( -center. x , -center. y )
602+ . post_scale ( scale. width , scale. height )
603+ . post_translate ( center. x , center. y ) ;
586604
587605 self . vector_pipeline . draw (
588606 handle,
589607 * color,
590608 physical_bounds,
591- _pixels,
609+ pixels,
610+ transform,
592611 clip_mask,
593612 ) ;
594613 }
0 commit comments