I have a System.Drawing.Drawing2D.Matrix with rotation and translation transforms which I need to apply to a sprite. Unfortunately rotation origin is in the upper left corner of the sprite.
How to change a rotation origin to the center of the sprite?
Unfortunately, none of the proposed solutions are working for me. They seems to be a good solutions and probably will work on another scenarios but not in my case.
However, I found a solution which works:
I’ve changed values for OffsetX and OffsetY fields of the matrix to following:
Where hx is half width, hy is half height of the sprite and M11, M12 and M21 – corresponding matrix fields.