I'm cropping a image in java swing, but when I select a part of image for cropping, I need to make selection part visible to user. Like a transparent rectangle on that image.
我在java swing中裁剪图像,但是当我选择一部分图像进行裁剪时,我需要让选择部分对用户可见。就像该图像上的透明矩形一样。
1 个解决方案
#1
2
GraphPanel
shows one approach to rendering such a selection rectangle, mouseRect
. The rendering is controlled by the boolean selecting
attribute.
GraphPanel显示了一种渲染这种选择矩形的方法mouseRect。渲染由布尔选择属性控制。
Addendum: Once you know the bounds of the selection, you can use getSubimage()
to clone the corresponding part of the image. There's a related example here.
附录:一旦知道了选择的边界,就可以使用getSubimage()来克隆图像的相应部分。这里有一个相关的例子。
#1
2
GraphPanel
shows one approach to rendering such a selection rectangle, mouseRect
. The rendering is controlled by the boolean selecting
attribute.
GraphPanel显示了一种渲染这种选择矩形的方法mouseRect。渲染由布尔选择属性控制。
Addendum: Once you know the bounds of the selection, you can use getSubimage()
to clone the corresponding part of the image. There's a related example here.
附录:一旦知道了选择的边界,就可以使用getSubimage()来克隆图像的相应部分。这里有一个相关的例子。