如何旋转JXImagePanel?
我想旋转 JXImagePanel。应该是可能的 - 这是关于JXImagePanel
:
虽然 JLabel
和 JButton
允许您轻松地将图像添加到 Swing 应用程序中, JXImagePanel
使得向 Swing 应用程序添加任何 BufferedImage
或 Icon
变得非常简单。
如果可编辑,它还为用户提供了更改图像的方法。此外,JXImagePanel
提供了许多开箱即用的内置效果, 包括平铺
、缩放
、旋转
、合成
等。
但是,我不知道该怎么做。目前我的代码片段是:
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
度。怎样才能做到呢?
I would to rotate JXImagePanel. It should be possible - this is about JXImagePanel
:
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.
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);
Now I would like to rotate it in 0-360
degrees. How it can be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
JXImagePanel 已被弃用(实际上,从 1.6.2 开始将包设为私有,因为它仍在内部使用),所以最好不要使用,很快就会被删除。
相反,使用带有 ImagePainter 的 JXPanel 和应用于画家的任意 TransformOp,在代码片段中类似:
您可能需要进行一些操作才能获得您想要实现的确切效果。对于问题,您可能想尝试在 Swinglabs 论坛上发帖。
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.
Instead, use a JXPanel with an ImagePainter and an arbitrary transformOp applied to the painter, in code snippets something like:
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.
我不知道更多关于
SwingX 的 JXImagePanel
的事情,但是对于普通的 Swing 来说,存在优秀的解决方法(由 aephyr 或 tjacobs 或......我讨厌来自 old.forums.sun.com 的这种无休止的混乱Sn'Oracle eerrrght)I don't know somethimg more about
SwingX's JXImagePanel
but for plain vanilla Swing there exists excelent workaround (by aephyr or tjacobs or ... I hate this endless-mess from old.forums.sun.com by Sn'Oracle eerrrght)