制作绘图应用程序的屏幕截图 +绘制二维形状的轮廓

发布于 2024-08-31 07:08:17 字数 242 浏览 3 评论 0原文

我正在制作一个绘图程序,通过将图形 2D 对象(即线条、矩形和椭圆形)放置在面板上来使用它们。考虑到这一点,我有两个问题:

1)如何将当前在面板上描绘的图像作为 PNG、JPG 或类似文件存储到磁盘上?

2)我添加了拖动功能。如何实现一个功能,以便在将矩形、直线或椭圆形实际放置到画布上之前可以看到矩形、直线或椭圆形的“轮廓”(但在释放鼠标按钮后不将轮廓放置在画布上)?我看不到任何 MouseListener 方法可以做这样的事情。

I am making a drawing program, using the Graphics 2D objects (lines, rectangles and ovals, namely) by placing them on a panel. With that in mind, I have 2 questions:

1) How can I store the images currently portrayed on the panel as PNG, JPG or similar file onto disk?

2) I have added a drag function. How can I implement a function so that one can see the "outline" of the rectangle, line or oval, before it is actually put onto the canvas (but not placing the outline on the canvas after the mouse button has been released)? I can't see that any of the MouseListener methods can do such a thing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

就是爱搞怪 2024-09-07 07:08:17

1) 如何存储图像
目前在面板上描绘为
PNG、JPG 或类似文件保存到磁盘上?

您可以创建 BufferedImage 并在其上绘制任何组件。 屏幕图像 类可以为您完成此操作。

1) How can I store the images
currently portrayed on the panel as
PNG, JPG or similar file onto disk?

You can create a BufferedImage and paint any component onto it. The Screen Image class does this for you.

夜巴黎 2024-09-07 07:08:17

2)如何实现一个功能,以便人们可以看到矩形、直线或椭圆形的“轮廓”?

在此示例中,可以拖动形状本身,而不是其轮廓,但是Node 类的 draw() 方法可以根据需要进行修改。矩形轮廓用于选择,就像在桌面上一样。

2) How can I implement a function so that one can see the "outline" of the rectangle, line or oval?

In this example, the shape itself may be dragged, rather than its outline, but the draw() method of class Node may be modified as desired. A rectangular outline is used for selection, as on a desktop.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文