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:
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user