• <bdo id='I8OiW'></bdo><ul id='I8OiW'></ul>

  • <tfoot id='I8OiW'></tfoot>

  • <small id='I8OiW'></small><noframes id='I8OiW'>

    <legend id='I8OiW'><style id='I8OiW'><dir id='I8OiW'><q id='I8OiW'></q></dir></style></legend>

      <i id='I8OiW'><tr id='I8OiW'><dt id='I8OiW'><q id='I8OiW'><span id='I8OiW'><b id='I8OiW'><form id='I8OiW'><ins id='I8OiW'></ins><ul id='I8OiW'></ul><sub id='I8OiW'></sub></form><legend id='I8OiW'></legend><bdo id='I8OiW'><pre id='I8OiW'><center id='I8OiW'></center></pre></bdo></b><th id='I8OiW'></th></span></q></dt></tr></i><div id='I8OiW'><tfoot id='I8OiW'></tfoot><dl id='I8OiW'><fieldset id='I8OiW'></fieldset></dl></div>

        SwingFXUtils 替代图像序列化(Javafx、Swing、Raspberry Pi)

        SwingFXUtils alternative for Image serialization (Javafx, Swing, Raspberry Pi)(SwingFXUtils 替代图像序列化(Javafx、Swing、Raspberry Pi))

            <legend id='TSRuj'><style id='TSRuj'><dir id='TSRuj'><q id='TSRuj'></q></dir></style></legend>

            <small id='TSRuj'></small><noframes id='TSRuj'>

              <tbody id='TSRuj'></tbody>
          1. <i id='TSRuj'><tr id='TSRuj'><dt id='TSRuj'><q id='TSRuj'><span id='TSRuj'><b id='TSRuj'><form id='TSRuj'><ins id='TSRuj'></ins><ul id='TSRuj'></ul><sub id='TSRuj'></sub></form><legend id='TSRuj'></legend><bdo id='TSRuj'><pre id='TSRuj'><center id='TSRuj'></center></pre></bdo></b><th id='TSRuj'></th></span></q></dt></tr></i><div id='TSRuj'><tfoot id='TSRuj'></tfoot><dl id='TSRuj'><fieldset id='TSRuj'></fieldset></dl></div>
              <bdo id='TSRuj'></bdo><ul id='TSRuj'></ul>
              • <tfoot id='TSRuj'></tfoot>

                1. 本文介绍了SwingFXUtils 替代图像序列化(Javafx、Swing、Raspberry Pi)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的 JavaFX 应用程序的一个用例是在一侧加载图像,通过 TCP 套接字对其进行序列化,以在另一侧将其显示为 JavaFX 图像.

                  One of the use cases of my JavaFX application is to load an image on one side, serialize it over a TCP socket to show it as JavaFX image on the other side.

                  为了实现这一点,我使用 SwingFXUtils.fromFXImage()SwingFXUtils.toFXImage() 来创建和读取一个 BufferedImage 可以是序列化.

                  To implement this I am using SwingFXUtils.fromFXImage() and SwingFXUtils.toFXImage() to create and read a BufferedImage which can be serialized.

                  一切正常.但我想在树莓派上运行显示面.我发现,在 ARM 上的 JavaFX 中没有集成 Swing 组件,因此在 Raspi 上使用 SwingFXUtils 时会得到 NoClassDefFoundError.

                  Everything is working. But I would like to run the displaying side on a raspberry pi. As I found out, there is no integration of Swing components in JavaFX on ARM, so I get a NoClassDefFoundError when using SwingFXUtils on a Raspi.

                  请建议我如何在不使用 SwingFXUtils 的情况下创建和读取可序列化的图像对象?

                  Please suggest how I can create and read a serializable image object without the use of SwingFXUtils?

                  推荐答案

                  感谢您的回答.

                  @haraldK 当然,我在序列化之前已经将我的 BufferedImage 写入了 ByteArray.我昨晚的解释不够准确.过失.

                  @haraldK of course i have written my BufferedImage to a ByteArray before serialization. My explanation last night wasn't exact enough. Mea culpa.

                  我找到了解决问题的方法:为了让它在 Raspberry Pi 上工作,我只是用 InputStream 替换了 BufferedImage 来读取我的 ByteArray 包含图像数据.这允许我使用 InputStream 而不是使用 SwingFXUtils 创建 JavaFX Image 对象.

                  I found a solution for my problem: To make it work on a Raspberry Pi I just substituted BufferedImage with an InputStream to read my ByteArray containing the image data. This allowed me to create the JavaFX Image object with an InputStream instead of using SwingFXUtils.

                  之前:

                  BufferedImage bufferedImage = ImageIO.read(new ByteArrayInputStream(imageUpdate.getImageByteArray()));
                  
                  imageView.setImage(SwingFXUtils.toFXImage(bufferedImage, null));
                  

                  ,其中 imageUpdate 是一个 ImageUpdate 对象,用于通过 TCP 套接字传输数据(包含图像和附加数据).

                  , where imageUpdate is an ImageUpdate Object used for data transport over TCP sockets (containing image and additional data).

                  如前所述,这会产生

                  Exception in thread "..." java.lang.NoClassDefFoundError: javafx/embed/swing/JFXPanel
                  

                  在 Raspberry Pi 上,因为 ARM 架构的 JavaFX 端口中缺少 Swing 类.

                  on the Raspberry Pi because of missing Swing Classes in JavaFX Port for ARM architecture.

                  之后:

                  InputStream inputStream = new ByteArrayInputStream(imageUpdate.getImageByteArray());
                  
                  imageView.setImage(new Image(inputStream));
                  

                  这个解决方案现在就像我的 Raspberry Pi 上的魅力一样.

                  This solution works now like a charm on my Raspberry Pi.

                  这篇关于SwingFXUtils 替代图像序列化(Javafx、Swing、Raspberry Pi)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                  <legend id='gbyzw'><style id='gbyzw'><dir id='gbyzw'><q id='gbyzw'></q></dir></style></legend>
                    • <bdo id='gbyzw'></bdo><ul id='gbyzw'></ul>
                        <tfoot id='gbyzw'></tfoot>

                            <small id='gbyzw'></small><noframes id='gbyzw'>

                              <tbody id='gbyzw'></tbody>
                          • <i id='gbyzw'><tr id='gbyzw'><dt id='gbyzw'><q id='gbyzw'><span id='gbyzw'><b id='gbyzw'><form id='gbyzw'><ins id='gbyzw'></ins><ul id='gbyzw'></ul><sub id='gbyzw'></sub></form><legend id='gbyzw'></legend><bdo id='gbyzw'><pre id='gbyzw'><center id='gbyzw'></center></pre></bdo></b><th id='gbyzw'></th></span></q></dt></tr></i><div id='gbyzw'><tfoot id='gbyzw'></tfoot><dl id='gbyzw'><fieldset id='gbyzw'></fieldset></dl></div>