如何在 eclipse e4 rcp 的 TreeViewer 中选择节点时加载和显示图像?
How to load and display an image on selection of a Node in TreeViewer in eclipse e4 rcp?
我正在尝试从用户选择的输入文件加载图像并使用 Label
将其显示给用户。此图像是所选 TreeViewer
节点的 属性。 So when selection changes the image (if exists) should be changed as well. (Master/Detail 情景)
论坛 post How to load image to view in RCP? 建议我必须手动读取图像作为 byte
数组。
是否有框架提供直接加载和显示图片的方式? Also if such a way exists what do I have to do to replace the image with a new one when selection changes?这样一次内存中只有一张图片。
要读取图像,请使用:
ImageDescriptor desc = ImageDescriptor.createFromFile(null, "file path");
Image image = desc.createImage();
不要忘记在处理完图像后进行处理。
我正在尝试从用户选择的输入文件加载图像并使用 Label
将其显示给用户。此图像是所选 TreeViewer
节点的 属性。 So when selection changes the image (if exists) should be changed as well. (Master/Detail 情景)
论坛 post How to load image to view in RCP? 建议我必须手动读取图像作为 byte
数组。
是否有框架提供直接加载和显示图片的方式? Also if such a way exists what do I have to do to replace the image with a new one when selection changes?这样一次内存中只有一张图片。
要读取图像,请使用:
ImageDescriptor desc = ImageDescriptor.createFromFile(null, "file path");
Image image = desc.createImage();
不要忘记在处理完图像后进行处理。