Skip to content

Refresh image dimensions after quarter-turn rotations - #194

Merged
HexDecimal merged 1 commit into
libtcod:mainfrom
antonsoo:fix/rotated-image-dimensions
Oct 12, 2026
Merged

HexDecimal merged 1 commit into
libtcod:mainfrom
antonsoo:fix/rotated-image-dimensions

Conversation

@antonsoo

Copy link
Copy Markdown
Contributor

Image.rotate90() updates native pixels but leaves the Python width and height unchanged. For a rectangular image, np.asarray(image) consequently returns the rotated pixels with the old shape.

Refresh the dimensions from the native image after rotating. Regressions cover rectangular and square images, signed/full turn counts, and repeated quarter turns.

A photograph-based array-to-semigraphics workflow matches NumPy rotation and a separately rendered reference console after the fix. Before, 20 of 54 configurations produced incorrect images and 30,720 differing console tiles; all 34 unaffected configurations remain identical.

Validation: 11 regressions fail before and all 28 pass after. The full native --no-window suite passes 309 tests with 95 rendering skips; applicable hooks and two-file Mypy pass. Tested on Linux/Python 3.12.

@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.08%. Comparing base (432932a) to head (86afe21).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #194   +/-   ##
=======================================
  Coverage   86.08%   86.08%           
=======================================
  Files          29       29           
  Lines        7589     7590    +1     
=======================================
+ Hits         6533     6534    +1     
  Misses       1056     1056           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@HexDecimal HexDecimal left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never gave the libtcod image port the scrutiny it deserved. It was a mistake for me to port it like this, and naturally I only tested rotation on a square image.

Thanks for fixing this.

@HexDecimal
HexDecimal merged commit 51e4832 into libtcod:main Oct 12, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants