我有一个字节数组中的 BMP。我想使用 SWT 在 Eclipse 插件中显示 BMP。
如果我想使用 swing 显示 BMP - 可以按如下方式完成:
BufferedImage bufferedImage = null;
try {
bufferedImage = ImageIO.read(new ByteArrayInputStream(getLocalByteArray()));
} catch (IOException ex) {
}
JLabel jLabel = new JLabel(new ImageIcon(bufferedImage));
JPanel jPanel = new JPanel();
jPanel.add(jLabel);
this.add(jPanel);
更新: BMP 将表示为字节数组。这是这个的先决条件。
如何使用 SWT 在 Eclipse 插件中执行此操作?请注意,我正在使用透视图。
最佳答案
SWT Image
可以直接从输入流创建。支持多种数据格式,包括 Windows 格式的 BMP。
例如:
Image image = new Image( display, new ByteArrayInputStream( ... ) );
生成的图像可以设置在标签
上或在其他地方使用。
关于java - 使用 SWT 在 Eclipse 插件透视图中加载 BMP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37333532/