[英]BufferedImage Rotation
What is the best way of rotating a bufferedimage about its center where the gradient is 1 degree? 围绕其倾斜度为1度的中心旋转缓冲图像的最佳方法是什么?
I know there is AffineTransform, but that causes shearing and weird stretching or black spots that should be blank. 我知道有AffineTransform,但这会导致剪切和怪异的拉伸或应为空白的黑点。
edit The sizes of images I am dealing with are icon sizes, so typically 24x24 up to 48x48 pixels 编辑我要处理的图像大小是图标大小,因此通常为24x24到48x48像素
The quality of rotation for such a small angle will vary greatly with the size of the image. 如此小的角度的旋转质量将随图像大小而变化很大。 How big is your image?
您的形象有多大?
[After the OP edited the question to indicate the size of the image] [OP编辑问题以指示图像大小后]
IMO the image is too small for any meaningful rotation other than in multiples of 90 degrees (assuming its a square). IMO图像对于任何有意义的旋转而言都太小了,除了90度的倍数(假设其为正方形)以外。 I am afraid this needs to be done manually by a graphic designer to get the best possible quality.
恐怕这需要由图形设计师手动完成才能获得最佳质量。
[Another alternative] [另一种选择]
Keep a high res version of the image around. 保持图像的高分辨率版本。 Apply all your transformations to this image and then scale down to obtain an icon.
将所有变换应用于此图像,然后按比例缩小以获取图标。
Have you tried setting the anti-aliasing of your graphics context? 您是否尝试过设置图形上下文的抗锯齿功能?
g2d.setRenderingHint(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON
);
As a quick and dirty fix, have you considered the following method: 作为快速而肮脏的修复程序,您是否考虑过以下方法:
Any low-level artefacts should vanish during the scale-down. 在缩小过程中,任何低水平的文物都应消失。 This isn't perhaps the fastest option, but it may well do what you want with a minimum of fuss - and more complex solutions may likely boil down to doing the same thing behind the scenes.
这可能不是最快的选择,但它可能会以最小的麻烦来做您想要的事情-更复杂的解决方案可能会归结为在幕后做同样的事情。
Here are some links which explain how you might want to proceed when applying transforms to icons. 以下是一些链接,这些链接说明了将变换应用于图标时可能要如何进行。
Java 2D Trickery: Antialiased Image Transforms http://weblogs.java.net/blog/campbell/archive/2007/03/java_2d_tricker_1.html Java 2D技巧:抗锯齿图像转换 http://weblogs.java.net/blog/campbell/archive/2007/03/java_2d_tricker_1.html
Sub pixel sampling of Raster or DataBuffer in BufferedImage. BufferedImage中的Raster或DataBuffer的子像素采样。 http://forums.java.net/jive/thread.jspa?messageID=204921&tstart=0
http://forums.java.net/jive/thread.jspa?messageID=204921&tstart=0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.