Image.this
- this(Device device, int width, int height)
- this(Device device, Image srcImage, int flag)
- this(Device device, Rectangle bounds)
- this(Device device, ImageData data)
- this(Device device, ImageData source, ImageData mask)
- this(Device device, InputStream stream)
- this(Device device, String filename)
orgeclipseswtgraphicsImageImage
constructorsfunctionsstatic functionsstatic variablesvariables
Constructs an instance of this class by loading its representation from the specified input stream. Throws an error if an error occurs while loading the image, or if the result is an image of an unsupported type. Application code is still responsible for closing the input stream. <p> This constructor is provided for convenience when loading a single image only. If the stream contains multiple images, only the first one will be loaded. To load multiple images, use <code>ImageLoader.load()</code>. </p><p> This constructor may be used to load a resource as follows: </p> <pre> static Image loadImage (Display display, Class clazz, String string) { InputStream stream = clazz.getResourceAsStream (string); if (stream is null) return null; Image image = null; try { image = new Image (display, stream); } catch (SWTException ex) { } finally { try { stream.close (); } catch (IOException ex) {} } return image; } </pre>
@param device the device on which to create the image @param stream the input stream to load the image from
@exception IllegalArgumentException <ul> <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li> <li>ERROR_NULL_ARGUMENT - if the stream is null</li> </ul> @exception SWTException <ul> <li>ERROR_IO - if an IO error occurs while reading from the stream</li> <li>ERROR_INVALID_IMAGE - if the image stream contains invalid data </li> <li>ERROR_UNSUPPORTED_DEPTH - if the image stream describes an image with an unsupported depth</li> <li>ERROR_UNSUPPORTED_FORMAT - if the image stream contains an unrecognized format</li> </ul> @exception SWTError <ul> <li>ERROR_NO_HANDLES if a handle could not be obtained for image creation</li> </ul>