Fixed getGridPosition for rotated images