Pcbnew: Fix rotating bitmaps

Fixes rotating bitmaps with "rotate counterclockwise",
"rotate clockwise" and "move exactly" commands.

Only rotation by 0, 90, 180 and 270 degrees is supported
for bitmaps. Other values are rounded to the nearest 90
degree multiple.

There is a different bug that this commit doesn't address,
which is that BITMAP_BASE::Rotate() got its CW/CCW logic
reversed ("m_image->Rotate( false )" should rotate CW, but
does not).

Fixes https://gitlab.com/kicad/code/kicad/issues/14197


(cherry picked from commit 45b94a4b3e)
This commit is contained in:
Martin Thierer 2023-03-14 23:26:20 +01:00 committed by Jon Evans
parent 874191bd8d
commit 640f279abe
1 changed files with 8 additions and 1 deletions

View File

@ -179,8 +179,15 @@ void PCB_BITMAP::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
void PCB_BITMAP::Rotate( const VECTOR2I& aCenter, const EDA_ANGLE& aAngle ) void PCB_BITMAP::Rotate( const VECTOR2I& aCenter, const EDA_ANGLE& aAngle )
{ {
EDA_ANGLE norm( aAngle.AsDegrees(), DEGREES_T );
RotatePoint( m_pos, aCenter, aAngle ); RotatePoint( m_pos, aCenter, aAngle );
m_image->Rotate( false );
norm.Normalize();
// each call to m_image->Rotate() rotates 90 degrees CCW
for( double ang = 45.0; ang < norm.AsDegrees(); ang += 90.0 )
m_image->Rotate( false );
} }