Fix image rotation direction in BITMAP_BASE::Rotate

The wxImage::Rotate90() parameter means "clockwise" when true, but the
code was passing aRotateCCW directly. This caused the pixel rotation to
be opposite to the intended direction. The bug manifested as images
appearing incorrectly after save/reload, since the OpenGL renderer uses
m_originalImage with m_rotation compensation, while after reload the
already-rotated pixels have no rotation compensation.

Also updated the unit test that was written to match the buggy behavior,
and added a separate test case for CW rotation.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/22719
This commit is contained in:
Seth Hillbrand
2026-01-19 15:13:14 -08:00
parent 56b8309525
commit a02b5f2f1f
2 changed files with 35 additions and 7 deletions
+2 -1
View File
@@ -450,7 +450,8 @@ void BITMAP_BASE::Rotate( bool aRotateCCW )
int resY = m_image->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONY );
int unit = m_image->GetOptionInt( wxIMAGE_OPTION_RESOLUTIONUNIT );
*m_image = m_image->Rotate90( aRotateCCW );
// wxImage::Rotate90 parameter is "clockwise", so invert for CCW rotation
*m_image = m_image->Rotate90( !aRotateCCW );
m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONUNIT, unit );
m_image->SetOption( wxIMAGE_OPTION_RESOLUTIONX, resX );