Taking a look at SWT Images:网上教程
org.eclipse.swt.graphics 包情况:
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);
.......to be continue