Constructs an empty instance of this class with the specified width and height. The result may be drawn upon by creating a GC and using any of its drawing operations, as shown in the following example: <pre> Image i = new Image(device, width, height); GC gc = new GC(i); gc.drawRectangle(0, 0, 50, 50); gc.dispose(); </pre> <p> Note: Some platforms may have a limitation on the size of image that can be created (size depends on width, height, and depth). For example, Windows 95, 98, and ME do not allow images larger than 16M. </p>
Constructs a new instance of this class based on the provided image, with an appearance that varies depending on the value of the flag. The possible flag values are: <dl> <dt><b>{@link SWT#IMAGE_COPY}</b></dt> <dd>the result is an identical copy of srcImage</dd> <dt><b>{@link SWT#IMAGE_DISABLE}</b></dt> <dd>the result is a copy of srcImage which has a <em>disabled</em> look</dd> <dt><b>{@link SWT#IMAGE_GRAY}</b></dt> <dd>the result is a copy of srcImage which has a <em>gray scale</em> look</dd> </dl>
Constructs an empty instance of this class with the width and height of the specified rectangle. The result may be drawn upon by creating a GC and using any of its drawing operations, as shown in the following example: <pre> Image i = new Image(device, boundsRectangle); GC gc = new GC(i); gc.drawRectangle(0, 0, 50, 50); gc.dispose(); </pre> <p> Note: Some platforms may have a limitation on the size of image that can be created (size depends on width, height, and depth). For example, Windows 95, 98, and ME do not allow images larger than 16M. </p>
Constructs an instance of this class from the given <code>ImageData</code>.
Constructs an instance of this class, whose type is <code>SWT.ICON</code>, from the two given <code>ImageData</code> objects. The two images must be the same size. Pixel transparency in either image will be ignored. <p> The mask image should contain white wherever the icon is to be visible, and black wherever the icon is to be transparent. In addition, the source image should contain black wherever the icon is to be transparent. </p>
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>
Constructs an instance of this class by loading its representation from the file with the specified name. Throws an error if an error occurs while loading the image, or if the result is an image of an unsupported type. <p> This constructor is provided for convenience when loading a single image only. If the specified file contains multiple images, only the first one will be used.
Create the receiver's mask if necessary.
Destroy the receiver's mask if it exists.
Returns the color to which to map the transparent pixel, or null if the receiver has no transparent pixel. <p> There are certain uses of Images that do not support transparency (for example, setting an image into a button or label). In these cases, it may be desired to simulate transparency by using the background color of the widget to paint the transparent pixels of the image. Use this method to check which color will be used in these cases in place of transparency. This value may be set with setBackground(). <p>
Returns the bounds of the receiver. The rectangle will always have x and y values of 0, and the width and height of the image.
Returns an <code>ImageData</code> based on the receiver Modifications made to this <code>ImageData</code> will not affect the Image.
Invokes platform specific functionality to dispose a GC handle. <p> <b>IMPORTANT:</b> This method is <em>not</em> part of the public API for <code>Image</code>. 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. </p>
Invokes platform specific functionality to allocate a new GC handle. <p> <b>IMPORTANT:</b> This method is <em>not</em> part of the public API for <code>Image</code>. 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. </p>
Returns <code>true</code> if the image has been disposed, and <code>false</code> otherwise. <p> This method gets the dispose state for the image. When an image has been disposed, it is an error to invoke any other method using the image.
Compares the argument to the receiver, and returns true if they represent the <em>same</em> object using a class specific comparison.
Sets the color to which to map the transparent pixel. <p> There are certain uses of <code>Images</code> that do not support transparency (for example, setting an image into a button or label). In these cases, it may be desired to simulate transparency by using the background color of the widget to paint the transparent pixels of the image. This method specifies the color that will be used in these cases. For example: <pre> Button b = new Button(); image.setBackground(b.getBackground()); b.setImage(image); </pre> </p><p> The image may be modified by this operation (in effect, the transparent regions may be filled with the supplied color). Hence this operation is not reversible and it is not legal to call this function twice or with a null argument. </p><p> This method has no effect if the receiver does not have a transparent pixel value. </p>
Returns an integer hash code for the receiver. Any two objects that return <code>true</code> when passed to <code>equals</code> must return the same value for this method.
Returns a string containing a concise, human-readable description of the receiver. import tango.core.Exception;
Invokes platform specific functionality to allocate a new image. <p> <b>IMPORTANT:</b> This method is <em>not</em> part of the public API for <code>Image</code>. 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. </p>
Specifies the default scanline padding.
The global alpha value to be used for every pixel.
The alpha data of the image.
The height of the image.
The handle to the OS mask resource. (Warning: This field is platform dependent) <p> <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT public API. 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 accessed from application code. </p>
The GC the image is currently selected in.
The handle to the OS pixmap resource. (Warning: This field is platform dependent) <p> <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT public API. 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 accessed from application code. </p>
specifies the transparent pixel
specifies whether the receiver is a bitmap or an icon (one of <code>SWT.BITMAP</code>, <code>SWT.ICON</code>) <p> <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT public API. 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 accessed from application code. </p>
The width of the image.
the device where this resource was created
Disposes of the operating system resources associated with this resource. Applications must dispose of all resources which they allocate.
Returns the <code>Device</code> where this resource was created.
Returns <code>true</code> if the resource has been disposed, and <code>false</code> otherwise. <p> This method gets the dispose state for the resource. When a resource has been disposed, it is an error to invoke any other method using the resource.
Invokes platform specific functionality to allocate a new GC handle. <p> <b>IMPORTANT:</b> This method is <em>not</em> part of the public API for <code>Drawable</code>. 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. </p>
Invokes platform specific functionality to dispose a GC handle. <p> <b>IMPORTANT:</b> This method is <em>not</em> part of the public API for <code>Drawable</code>. 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. </p>
Instances of this class are graphics which have been prepared for display on a specific device. That is, they are ready to paint using methods such as <code>GC.drawImage()</code> and display on widgets with, for example, <code>Button.setImage()</code>. <p> If loaded from a file format that supports it, an <code>Image</code> may have transparency, meaning that certain pixels are specified as being transparent when drawn. Examples of file formats that support transparency are GIF and PNG. </p><p> There are two primary ways to use <code>Images</code>. The first is to load a graphic file from disk and create an <code>Image</code> from it. This is done using an <code>Image</code> constructor, for example: <pre> Image i = new Image(device, "C:\\graphic.bmp"); </pre> A graphic file may contain a color table specifying which colors the image was intended to possess. In the above example, these colors will be mapped to the closest available color in SWT. It is possible to get more control over the mapping of colors as the image is being created, using code of the form: <pre> 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); </pre> <p> Applications which require even greater control over the image loading process should use the support provided in class <code>ImageLoader</code>. </p><p> Application code must explicitly invoke the <code>Image.dispose()</code> method to release the operating system resources managed by each instance when those instances are no longer required. </p>
@see Color @see ImageData @see ImageLoader @see <a href="http://www.eclipse.org/swt/snippets/#image">Image snippets</a> @see <a href="http://www.eclipse.org/swt/examples.php">SWT Examples: GraphicsExample, ImageAnalyzer</a> @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>