获得Image对象的几个方法

1 . 
    Image.win32_new (Display.getDefault(), SWT.ICON, 65545)
Image org.eclipse.swt.graphics.Image.win32_new(Device device, int type, int handle)

Invokes platform specific functionality to allocate a new image.

IMPORTANT: This method is not part of the public API for Image. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms, and should never be called from application code.

参数:
device the device on which to allocate the color
type the type of the image (SWT.BITMAP or SWT.ICON)
handle the OS handle for the image
返回:
a new image object containing the specified device, type and handle
2 . 
    Display.getDefault().getSystemImage(SWT.ICON_WORKING)
Image org.eclipse.swt.widgets.Display.getSystemImage(int id)

Returns the matching standard platform image for the given constant, which should be one of the icon constants specified in class SWT. This image should not be free‘d because it was allocated by the system, not the application. A value of null will be returned either if the supplied constant is not an swt icon constant or if the platform does not define an image that corresponds to the constant.

参数:
id the swt icon constant
返回:
the corresponding image or null
抛出:
SWTException
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • ERROR_DEVICE_DISPOSED - if the receiver has been disposed
另请参阅:
SWT.ICON_ERROR
SWT.ICON_INFORMATION
SWT.ICON_QUESTION
SWT.ICON_WARNING
SWT.ICON_WORKING
@since
3.0
3。
   AbstractUIPlugin.imageDescriptorFromPlugin(Application.ID,"icons/types.gif")
ImageDescriptor org.eclipse.ui.plugin.AbstractUIPlugin.imageDescriptorFromPlugin(String pluginId, String imageFilePath)

Creates and returns a new image descriptor for an image file located within the specified plug-in.

This is a convenience method that simply locates the image file in within the plug-in (no image registries are involved). The path is relative to the root of the plug-in, and takes into account files coming from plug-in fragments. The path may include $arg$ elements. However, the path must not have a leading "." or path separator. Clients should use a path like "icons/mysample.gif" rather than "./icons/mysample.gif" or "/icons/mysample.gif".

参数:
pluginId the id of the plug-in containing the image file; null is returned if the plug-in does not exist
imageFilePath the relative path of the image file, relative to the root of the plug-in; the path must be legal
返回:
an image descriptor, or null if no image could be found
注 :Application.ID:插件ID

4。
static final Image
    UNCHECKED = createImage("images/checkboxenabledoff.gif"), //$NON-NLS-1$
    CHECKED = createImage("images/checkboxenabledon.gif"); //$NON-NLS-1$

private static Image createImage(String name) {
    InputStream stream = CheckBox.class.getResourceAsStream(name);
    Image image = new Image(null, stream);
    try {
        stream.close();
    } catch (IOException ioe) {
    }
    return image;
}

5。
        ImageRegistry reg = JFaceResources.getImageRegistry();
        reg.put(CELL_EDITOR_IMG_DOTS_BUTTON, ImageDescriptor.createFromFile(
                DialogCellEditor.class, "images/dots_button.gif"));
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值