It seems to me that the changes to this file would be much simpler if you handled the rotation at the top of this function, and modified width, height and scale based on the orientation.  If you do that, can't you leave many of the remaining calculations unmodified?

Or maybe even handle the orientation when displayImage() is first called by setting itemWidth and itemHeight based on the rotation?

Would that simplify things?