我想旋转 JXImagePanel.应该有可能 - 这是关于 JXImagePanel
:
I would to rotate JXImagePanel. It should be possible - this is about JXImagePanel
:
虽然 JLabel
和 JButton
允许您轻松地将图像添加到 Swing 应用程序,JXImagePanel
使得将任何 BufferedImage
或 Icon
添加到 Swing 应用程序变得非常容易.
While JLabel
and JButton
allow you to easily add images to your Swing applications,
the JXImagePanel
makes it trivially easy to add any BufferedImage
or Icon
to your Swing applications.
如果可编辑,它还为用户提供了一种更改图像的方法.此外,JXImagePanel
提供了许多开箱即用的内置效果,包括Tiling
、Scaling
、Rotating
、Compositing
等等.
If editable, it also provides a way for the user to change the image. In addition, the JXImagePanel
provides many built in effects out-of-the-box,
including Tiling
, Scaling
, Rotating
, Compositing
, and more.
但是,我不知道该怎么做.目前我的代码片段是:
However, I cannot figure out how to do this. Currently my code snippet is:
bufferedImage = ImageIO.read(new File("image.png"));
image = new ImageIcon(bufferedImage).getImage();
tempImage = image.getScaledInstance(100, 150, Image.SCALE_FAST);
this.deskJXImagePanel.setImage(tempImage);
现在我想将它旋转 0-360
度.怎么做?
Now I would like to rotate it in 0-360
degrees. How it can be done?
JXImagePanel 已被弃用(实际上,从 1.6.2 开始将包设为私有,因为它仍在内部使用),所以最好不要使用 is,很快就会被删除.
JXImagePanel is deprecated (actually, made package private as of 1.6.2, because it's still used internally), so better not use is, will be removed soon.
相反,使用带有 ImagePainter 的 JXPanel 和应用于画家的任意 transformOp,在代码片段中类似于:
Instead, use a JXPanel with an ImagePainter and an arbitrary transformOp applied to the painter, in code snippets something like:
JXPanel panel = new JXPanel();
ImagePainter image = new ImagePainter(myImage);
image.setFilters(
new AffineTransformOp(AffineTransform.getRotateInstance(-Math.PI * 2 / 8, 100, 100), null)
);
panel.setBackgroundPainter(image);
您可能需要花一点时间才能获得您想要达到的确切效果.如果遇到问题,您可能想尝试在 Swinglabs 论坛上发帖.
you'll probably have to play a bit to get the exact effects you want to achieve. On problems, you might want to try posting to the Swinglabs forum.
这篇关于如何旋转 JXImagePanel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!