gpt4 book ai didi

java - 如何从插件内部资源中获取图像?

转载 作者:行者123 更新时间:2023-11-29 05:07:04 25 4
gpt4 key购买 nike

我正在尝试使用 SWT Image 从我的插件资源中获取图像文件

Image image=new Image(device,"icons/imagename.png");

图标文件夹位于插件的类路径中,但我仍然收到 IOException

你能帮我指出从插件的内部资源访问图像资源的正确方法是什么吗?

最佳答案

使用类似的东西:

String path = "icons/imagename.png";
Bundle bundle = Platform.getBundle("plugin id");
URL url = FileLocator.find(bundle, new Path(path), null);
ImageDescriptor imageDesc = ImageDescriptor.createFromURL(url);
Image image = imageDesc.createImage();

不要忘记在处理完图像后必须对其进行处置。

关于java - 如何从插件内部资源中获取图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30031748/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com