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
This commit is contained in:
Seth Hillbrand 2020-01-11 09:44:54 -08:00
parent c3df984c0b
commit 195c3d074b
1 changed files with 9 additions and 4 deletions

View File

@ -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 );
}