|
Eclipse Remote Application Platform | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.swt.graphics.Resource org.eclipse.swt.graphics.Image
public final class Image
Instances of this class are graphics which have been prepared
for display on a specific device. That is, they are to display
on widgets with, for example, Button.setImage()
.
If loaded from a file format that supports it, an
Image
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.
Note: Even though constructors are provided here, it is
recommended to create images by using one of the getImage
methods in class Graphics
. These factory methods share images
among all sessions.
Creating images via constructors carelessly may lead to bad performance
and/or unnecessary memory consumption.
Graphics.getImage(String)
,
Graphics.getImage(String, ClassLoader)
,
Graphics.getImage(String, java.io.InputStream)
Field Summary | |
---|---|
InternalImage |
internalImage
The internal resource. |
Constructor Summary | |
---|---|
Image(Device device,
Image srcImage,
int flag)
Constructs a new instance of this class based on the provided image, with an appearance that varies depending on the value of the flag. |
|
Image(Device device,
int width,
int height)
Constructs an empty instance of this class with the specified width and height. |
Method Summary | |
---|---|
Color |
getBackground()
Returns the color to which to map the transparent pixel, or null if the receiver has no transparent pixel. |
Rectangle |
getBounds()
Returns the bounds of the receiver. |
ImageData |
getImageData()
Returns an ImageData based on the receiver
Modifications made to this ImageData will not
affect the Image. |
void |
setBackground(Color color)
Sets the color to which to map the transparent pixel. |
Methods inherited from class org.eclipse.swt.graphics.Resource |
---|
dispose, getDevice, isDisposed |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final InternalImage internalImage
IMPORTANT: This field is not 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.
Constructor Detail |
---|
public Image(Device device, Image srcImage, int flag)
SWT.IMAGE_COPY
device
- the device on which to create the imagesrcImage
- the image to use as the sourceflag
- the style, either IMAGE_COPY
, IMAGE_DISABLE
or IMAGE_GRAY
java.lang.IllegalArgumentException
- IMAGE_COPY
, IMAGE_DISABLE
or IMAGE_GRAY
SWTException
- SWTError
- public Image(Device device, int width, int height)
Image i = new Image(device, width, height); GC gc = new GC(i); gc.drawRectangle(0, 0, 50, 50); gc.dispose();
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.
device
- the device on which to create the imagewidth
- the width of the new imageheight
- the height of the new image
java.lang.IllegalArgumentException
- SWTError
- Method Detail |
---|
public Rectangle getBounds()
SWTException
- public ImageData getImageData()
ImageData
based on the receiver
Modifications made to this ImageData
will not
affect the Image.
ImageData
containing the image's data and attributes
SWTException
- ImageData
public void setBackground(Color color)
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. This method specifies the color that will be used in
these cases. For example:
Button b = new Button(); image.setBackground(b.getBackground()); b.setImage(image);
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.
This method has no effect if the receiver does not have a transparent pixel value.
color
- the color to use when a transparent pixel is specified
java.lang.IllegalArgumentException
- SWTException
- public Color getBackground()
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().
SWTException
-
|
Eclipse Remote Application Platform | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright (c) EclipseSource and others 2002, 2013. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0