有没有JavaFX图像编辑器? [英] Is there any JavaFX Image editor?

查看:192
本文介绍了有没有JavaFX图像编辑器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的JavaFX应用程序中添加一个简单的光栅图形编辑器。

似乎无法使用 javafx.scene.image.Image 因为图形对象是只读的。

有人能说我怎么能这样做,或者有些类可以直接访问像素图?

I want to put a simple raster graphics editor into my JavaFX app.
It seems that it can't be done using javafx.scene.image.Image because the graphics object is read-only.
Can somebody point me how can I do this or maybe there are some classes that provide direct access to pixel map?

upd:编辑器无需快速响应,因此建议a-la 创建隐藏 java.awt.Canvas ,处理ImageView上要在画布上绘制的所有事件,通过某种方式创建来自画布的输出流,以创建新的javafx Image并将其放到ImageView

upd: it is not necessary for editor to respond quickly, so the suggestions a-la create hidden java.awt.Canvas, handle all the events on ImageView to draw on the canvas, create by some means an output stream from the canvas to create new javafx Image and put it to ImageView.

推荐答案

你可以使用 JavaFX canvas 来执行此操作,如 Canvas Tutorial 与用户交互部分。你不需要 java.awt.Canvas

You can use a JavaFX canvas to do this as shown in the Canvas Tutorial "Interacting with the User" section. You don't need a java.awt.Canvas.

你可以采用快照用于创建图像的画布(或任何其他节点)。

You can take a snapshot of a canvas (or any other node) to create an image.

您可以使用 PixelWriter WritableImage ,如 ImageOps教程

要将生成的图像写入磁盘,将其转换为BufferedImage 并使用 ImageIO

To write your resultant image to disk, convert it to a BufferedImage and write it out using ImageIO.

如果需要,可以将缩放图像的样本设置为像素化形式(类似于Microsoft Paint中的缩放功能):没有任何平滑的JavaFX ImageView

If you need it, there are samples of scaling images to a pixelated form (similar to the zoom function in Microsoft Paint): JavaFX ImageView without any smoothing.

这篇关于有没有JavaFX图像编辑器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆