From b084115a9e5ff0ca8490f4f45bf3f8b48e93027c Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 20 Jan 2022 16:15:39 +0100 Subject: [PATCH] BITMAP_BASE::DrawBitmap(): fix position of the clipping area when using matrix transform. Fixes #10525 https://gitlab.com/kicad/code/kicad/issues/10525 --- common/bitmap_base.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/common/bitmap_base.cpp b/common/bitmap_base.cpp index 39e554edbb..3ca628c74e 100644 --- a/common/bitmap_base.cpp +++ b/common/bitmap_base.cpp @@ -253,12 +253,16 @@ void BITMAP_BASE::DrawBitmap( wxDC* aDC, const VECTOR2I& aPos ) bool useTransform = aDC->CanUseTransformMatrix(); wxAffineMatrix2D init_matrix = aDC->GetTransformMatrix(); + wxPoint clipAreaPos; + if( useTransform ) { wxAffineMatrix2D matrix = aDC->GetTransformMatrix(); matrix.Translate( pos.x, pos.y ); matrix.Scale( GetScalingFactor(), GetScalingFactor() ); aDC->SetTransformMatrix( matrix ); + clipAreaPos.x = pos.x; + clipAreaPos.y = pos.y; pos.x = pos.y = 0; } else @@ -271,10 +275,12 @@ void BITMAP_BASE::DrawBitmap( wxDC* aDC, const VECTOR2I& aPos ) pos.y = KiROUND( pos.y / GetScalingFactor() ); size.x = KiROUND( size.x / GetScalingFactor() ); size.y = KiROUND( size.y / GetScalingFactor() ); + clipAreaPos.x = pos.x; + clipAreaPos.y = pos.y; } aDC->DestroyClippingRegion(); - aDC->SetClippingRegion( wxPoint( pos.x, pos.y ), size ); + aDC->SetClippingRegion( clipAreaPos, size ); if( GetGRForceBlackPenState() ) {