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