Is there a more efficient way to rotate images in Java than AffineTransform?

半腔热情 提交于 2019-12-11 20:13:55

问题


I've looked around for ways to rotate BufferedImages in Java and all I have found is AffineTransform. That's fine, but it seems like a bit of overkill if all I want to do is rotate 90 degrees. Would it be more efficient to just do it pixel-by-pixel? Is there some other method I could use?


回答1:


From the Javadoc of the class you mention:

Handling 90-Degree Rotations

In some variations of the rotate methods in the AffineTransform class, a double-precision argument specifies the angle of rotation in radians. These methods have special handling for rotations of approximately 90 degrees (including multiples such as 180, 270, and 360 degrees), so that the common case of quadrant rotation is handled more efficiently.

That makes it seem like you shouldn't worry about performance without solid proof to the contrary.

In addition take note of the following method: quadrantRotate(int numQuadrants)



来源:https://stackoverflow.com/questions/25826838/is-there-a-more-efficient-way-to-rotate-images-in-java-than-affinetransform

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!