SWT.IMAGE

本文主要介绍了SWT框架中Images类和ImageLoader类的使用方法。Images提供了两种使用方式:直接加载图像和控制颜色分配加载图像。同时,文章还详细解释了如何使用ImageLoader类来保存图像。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Interfaces 
Drawable
ImageLoaderListener
Classes 
Color
Cursor
Device
DeviceData
Font
FontData
FontMetrics
GC
GCData
Image
ImageData
ImageLoader
ImageLoaderEvent
PaletteData
Point
Rectangle
Region
RGB

Images类使用介绍:
There are two primary ways to use Images.
1:直接调用
      Image i = new Image(device, "C://graphic.bmp");
      //device有2种设备,Display和Printer,写null,默认使用当前的Display来做显示设备。
2:控制颜色分配
    ImageData data = new ImageData("C://graphic.bmp");
    RGB[] rgbs = data.getRGBs();
    // At this point, rgbs contains specifications of all
    // the colors contained within this image. You may
    // allocate as many of these colors as you wish by
    // using the Color constructor Color(RGB), then
    // create the image:
    Image i = new Image(device, data);

相对路径:
Image i = new Image(device, "icons/graphic.bmp");   //项目根目录下

插件自带图像
ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages():
Image image = sharedImages.getImage(ISharedImages.IMG_OBJS_WARN_TSK);

ImageLoader类使用介绍:保存图片
ImageLoader imageLoader = new ImageLoader();
imageLoader.data = new ImageData[] {imageData};                 
//The reason the data field is an array of ImageData is to support
//image file formats with more than one frame such as animated GIFs or interlaced JPEG files.

imageLoader.save("C:/temp/Idea_PureWhite.jpg",SWT.IMAGE_JPEG);

kettle-webspoon 17-Jun-2025 09:04:16.616 信息 [Thread-129] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina] Exception while disposing shell: Shell {Spoon - [FileRepository] [没有名称]} org.eclipse.swt.SWTException: Graphic is disposed at org.eclipse.swt.SWT.error(SWT.java:3808) at org.eclipse.swt.SWT.error(SWT.java:3731) at org.eclipse.swt.SWT.error(SWT.java:3702) at org.eclipse.swt.graphics.Image.getBounds(Image.java:425) at org.eclipse.swt.widgets.ToolItem.getPreferredHeight(ToolItem.java:587) at org.eclipse.swt.widgets.ToolItem.getHeight(ToolItem.java:541) at org.eclipse.swt.widgets.ToolItem.getBounds(ToolItem.java:497) at org.eclipse.swt.widgets.ToolBar.layoutItems(ToolBar.java:385) at org.eclipse.swt.widgets.ToolBar.destroyItem(ToolBar.java:379) at org.eclipse.swt.widgets.ToolItem.releaseParent(ToolItem.java:805) at org.eclipse.swt.widgets.Widget.dispose(Widget.java:848) at org.eclipse.swt.widgets.ToolBar.releaseChildren(ToolBar.java:354) at org.eclipse.swt.widgets.Widget.dispose(Widget.java:844) at org.eclipse.swt.widgets.Composite.releaseChildren(Composite.java:873) at org.eclipse.swt.widgets.Shell.releaseChildren(Shell.java:992) at org.eclipse.swt.widgets.Widget.dispose(Widget.java:844) at org.eclipse.swt.widgets.Display.disposeShells(Display.java:763) at org.eclipse.swt.widgets.Display.release(Display.java:739) at org.eclipse.swt.graphics.Device.dispose(Device.java:279) at org.eclipse.rap.rwt.internal.lifecycle.UIThread.processShutdown(UIThread.java:179) at org.eclipse.rap.rwt.internal.lifecycle.RWTLifeCycle$UIThreadController.run(RWTLifeCycle.java:309) at java.lang.Thread.run(Thread.java:748) at org.eclipse.rap.rwt.internal.lifecycle.UIThread.run(UIThread.java:107) /usr/local/tomcat/bin/catalina.sh: line 149: /usr/local/tomcat/bin/setenv.sh: Operation not permitted
最新发布
07-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值