From 195c3d074b881c12a4e8b5570b2e64f219d55d72 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sat, 11 Jan 2020 09:44:54 -0800 Subject: [PATCH] Fix bitmap clipping When printing (using DC context) the bitmap will clear the full screen unless the clipping region is set to the image itself. Addresses KSC ticket 126 Fixes #1877 | https://gitlab.com/kicad/code/kicad/issues/1877 --- common/bitmap_base.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/common/bitmap_base.cpp b/common/bitmap_base.cpp index 6fb6b6e875..f470403d5a 100644 --- a/common/bitmap_base.cpp +++ b/common/bitmap_base.cpp @@ -261,10 +261,15 @@ void BITMAP_BASE::DrawBitmap( wxDC* aDC, const wxPoint& aPos ) aDC->SetUserScale( scale * GetScalingFactor(), scale * GetScalingFactor() ); aDC->SetLogicalOrigin( logicalOriginX / GetScalingFactor(), logicalOriginY / GetScalingFactor() ); - aDC->DrawBitmap( *m_bitmap, - KiROUND( pos.x / GetScalingFactor() ), - KiROUND( pos.y / GetScalingFactor() ), - true ); + + pos.x = KiROUND( pos.x / GetScalingFactor() ); + pos.y = KiROUND( pos.y / GetScalingFactor() ); + size.x = KiROUND( size.x / GetScalingFactor() ); + size.y = KiROUND( size.y / GetScalingFactor() ); + + aDC->SetClippingRegion( pos, size ); + aDC->DrawBitmap( *m_bitmap, pos.x, pos.y, true ); + aDC->DestroyClippingRegion(); aDC->SetUserScale( scale, scale ); aDC->SetLogicalOrigin( logicalOriginX, logicalOriginY ); }