BITMAP_BASE, Eeschema: fix incorrect position of the bitmap when printing.

The previous calculation was not compatible with aDC->SetTransformMatrix()
used in PrintPage in Eeschema.
This commit is contained in:
jean-pierre charras 2020-05-24 21:00:11 +02:00
parent ecec7192fc
commit 077611b8f1
1 changed files with 27 additions and 11 deletions

View File

@ -258,15 +258,27 @@ void BITMAP_BASE::DrawBitmap( wxDC* aDC, const wxPoint& aPos )
int logicalOriginX, logicalOriginY;
aDC->GetUserScale( &scale, &scale );
aDC->GetLogicalOrigin( &logicalOriginX, &logicalOriginY );
aDC->SetUserScale( scale * GetScalingFactor(), scale * GetScalingFactor() );
aDC->SetLogicalOrigin( logicalOriginX / GetScalingFactor(),
logicalOriginY / GetScalingFactor() );
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 );
bool useTransform = aDC->CanUseTransformMatrix();
wxAffineMatrix2D init_matrix = aDC->GetTransformMatrix();
if( useTransform )
{
wxAffineMatrix2D matrix = aDC->GetTransformMatrix();
matrix.Translate( pos.x, pos.y );
matrix.Scale( GetScalingFactor(), GetScalingFactor() );
aDC->SetTransformMatrix( matrix );
pos.x = pos.y = 0;
}
else
{
aDC->SetUserScale( scale * GetScalingFactor(), scale * GetScalingFactor() );
aDC->SetLogicalOrigin( logicalOriginX / GetScalingFactor(),
logicalOriginY / GetScalingFactor() );
pos.x = KiROUND( pos.x / GetScalingFactor() );
pos.y = KiROUND( pos.y / GetScalingFactor() );
}
if( GetGRForceBlackPenState() )
{
@ -278,9 +290,13 @@ void BITMAP_BASE::DrawBitmap( wxDC* aDC, const wxPoint& aPos )
aDC->DrawBitmap( *m_bitmap, pos.x, pos.y, true );
}
aDC->DestroyClippingRegion();
aDC->SetUserScale( scale, scale );
aDC->SetLogicalOrigin( logicalOriginX, logicalOriginY );
if( useTransform )
aDC->SetTransformMatrix( init_matrix );
else
{
aDC->SetUserScale( scale, scale );
aDC->SetLogicalOrigin( logicalOriginX, logicalOriginY );
}
}