Top Description Fields Constructors Methods
org.eclipse.swt.graphics

public final Class ImageData

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
java.io.*, org.eclipse.swt.*, org.eclipse.swt.internal.*

Instances of this class are device-independent descriptions of images. They are typically used as an intermediate format between loading from or writing to streams and creating an Image.

Note that the public fields x, y, disposalMethod and delayTime are typically only used when the image is in a set of images used for animation.

See Also
Image, ImageLoader, ImageData snippets, SWT Example: ImageAnalyzer, Sample code and further information

Field Summary

Modifier and TypeField and Description
public int
alpha

The global alpha value to be used for every pixel.

public byte[]
alphaData

The alpha data of the image.

pack-priv static final byte[][]
ANY_TO_EIGHT

Arbitrary channel width data to 8-bit conversion table.

public int
bytesPerLine

The number of bytes per scanline.

public byte[]
data

The pixel data of the image.

public int
delayTime

The time to delay before displaying the next image in an animation (this field corresponds to the GIF89a Delay Time value).

public int
depth

The color depth of the image, in bits per pixel.

public int
disposalMethod

A description of how to dispose of the current image before displaying the next.

pack-priv static final int[][]
DITHER_MATRIX

Scaled 8x8 Bayer dither matrix.

public int
height

The height of the image, in pixels.

pack-priv static final int
LSB_FIRST

Byte and bit order constants.

public byte[]
maskData

An icon-specific field containing the data from the icon mask.

public int
maskPad

An icon-specific field containing the scanline pad of the mask.

pack-priv static final int
public PaletteData
palette

The color table for the image.

public int
scanlinePad

The scanline padding.

public int
transparentPixel

The transparent pixel.

public int
type

The type of file from which the image was read.

private static final int
TYPE_GENERIC_16_LSB

Data types (internal)

private static final int
TYPE_GENERIC_16_MSB

Data types (internal)

private static final int
TYPE_GENERIC_24

Data types (internal)

private static final int
TYPE_GENERIC_32_LSB

Data types (internal)

private static final int
TYPE_GENERIC_32_MSB

Data types (internal)

private static final int
TYPE_GENERIC_8

Data types (internal)

private static final int
TYPE_INDEX_16_LSB

Data types (internal)

private static final int
TYPE_INDEX_1_LSB

Data types (internal)

private static final int
TYPE_INDEX_1_MSB

Data types (internal)

private static final int
TYPE_INDEX_2

Data types (internal)

private static final int
TYPE_INDEX_4

Data types (internal)

private static final int
TYPE_INDEX_8

Data types (internal)

public int
width

The width of the image, in pixels.

public int
x

The x coordinate of the top left corner of the image within the logical screen (this field corresponds to the GIF89a Image Left Position value).

public int
y

The y coordinate of the top left corner of the image within the logical screen (this field corresponds to the GIF89a Image Top Position value).

Constructor Summary

AccessConstructor and Description
public
ImageData(int
the width of the image
width
,
int
the height of the image
height
,
int
the depth of the image
depth
,
PaletteData
the palette of the image (must not be null)
palette
)

Constructs a new, empty ImageData with the given width, height, depth and palette.

public
ImageData(int
the width of the image
width
,
int
the height of the image
height
,
int
the depth of the image
depth
,
PaletteData
the palette of the image
palette
,
int
the padding of each line, in bytes
scanlinePad
,
byte[]
the data of the image
data
)

Constructs a new, empty ImageData with the given width, height, depth, palette, scanlinePad and data.

public
ImageData(InputStream
the input stream to load the image from (must not be null)
stream
)

Constructs an ImageData loaded from the specified input stream.

public
ImageData(String
the name of the file to load the image from (must not be null)
filename
)

Constructs an ImageData loaded from a file with the specified name.

pack-priv
ImageData()

Prevents uninitialized instances from being created outside the package.

pack-priv
ImageData(int width, int height, int depth, PaletteData palette, int scanlinePad, byte[] data, int maskPad, byte[] maskData, byte[] alphaData, int alpha, int transparentPixel, int type, int x, int y, int disposalMethod, int delayTime)

Constructs an image data by giving values for all non-computable fields.

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
blit(byte[]
the source byte array containing image data
srcData
,
int
the source depth: one of 8, 16, 24, 32
srcDepth
,
int
the source number of bytes per line
srcStride
,
int
the source byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if srcDepth is not 16 or 32
srcOrder
,
int
the width of the source blit region
srcWidth
,
int
the height of the source blit region
srcHeight
,
int
the source red channel mask
srcRedMask
,
int
the source green channel mask
srcGreenMask
,
int
the source blue channel mask
srcBlueMask
,
byte[]
the destination byte array containing image data
destData
,
int
the destination depth: one of 8, 16, 24, 32
destDepth
,
int
the destination number of bytes per line
destStride
,
int
the destination byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if destDepth is not 16 or 32
destOrder
,
int
the width of the destination blit region
destWidth
,
int
the height of the destination blit region
destHeight
,
int
the destination red channel mask
destRedMask
,
int
the destination green channel mask
destGreenMask
,
int
the destination blue channel mask
destBlueMask
,
boolean
if true the resulting image is flipped along the vertical axis
flipX
,
boolean
if true the resulting image is flipped along the horizontal axis
flipY
)

Blits a direct palette image into a direct palette image.

pack-priv static void
blit(byte[]
the source byte array containing image data
srcData
,
int
the source depth: one of 1, 2, 4, 8
srcDepth
,
int
the source number of bytes per line
srcStride
,
int
the source byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if srcDepth is not 1
srcOrder
,
int
the width of the source blit region
srcWidth
,
int
the height of the source blit region
srcHeight
,
byte[]
the destination byte array containing image data
destData
,
int
the destination depth: one of 1, 2, 4, 8
destDepth
,
int
the destination number of bytes per line
destStride
,
int
the destination byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if destDepth is not 1
destOrder
,
int
the width of the destination blit region
destWidth
,
int
the height of the destination blit region
destHeight
,
boolean
if true the resulting image is flipped along the vertical axis
flipX
,
boolean
if true the resulting image is flipped along the horizontal axis
flipY
)

Blits an index palette image into an index palette image.

pack-priv static void
blit(int
the width of the source blit region
srcWidth
,
int
the height of the source blit region
srcHeight
,
byte[]
the source byte array containing image data
srcData
,
int
the source depth: one of 1, 2, 4, 8
srcDepth
,
int
the source number of bytes per line
srcStride
,
int
the source byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if srcDepth is not 1
srcOrder
,
byte[]
the source palette red component intensities
srcReds
,
byte[]
the source palette green component intensities
srcGreens
,
byte[]
the source palette blue component intensities
srcBlues
,
byte[]
the destination byte array containing image data
destData
,
int
the destination depth: one of 8, 16, 24, 32
destDepth
,
int
the destination number of bytes per line
destStride
,
int
the destination byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if destDepth is not 16 or 32
destOrder
,
int
the destination red channel mask
destRedMask
,
int
the destination green channel mask
destGreenMask
,
int
the destination blue channel mask
destBlueMask
)

Blits an index palette image into a direct palette image.

pack-priv static void
buildDitheredGradientChannel(int from, int to, int steps, int bandWidth, int bandHeight, boolean vertical, byte[] bitmapData, int dp, int bytesPerLine, int bits)

pack-priv static void
buildPreciseGradientChannel(int from, int to, int steps, int bandWidth, int bandHeight, boolean vertical, byte[] bitmapData, int dp, int bytesPerLine)

pack-priv static PaletteData
bwPalette()

Returns a palette with 2 colors: black & white.

pack-priv static byte[]
checkData(byte[] data)

public Object

Returns:

a copy of the receiver.
clone
()

Overrides java.lang.Object.clone.

Returns a new instance of the same class as the receiver, whose slots have been filled in with copies of the values in the slots of the receiver.
pack-priv ImageData
colorMaskImage(int pixel)

pack-priv static ImageData
pack-priv static byte[]
convertPad(byte[] data, int width, int height, int depth, int pad, int newPad)

pack-priv static ImageData

Returns:

the new ImageData
createGradientBand
(int
the width of the region to be filled
width
,
int
the height of the region to be filled
height
,
boolean
if true sweeps from top to bottom, else sweeps from left to right
vertical
,
RGB
the color to start with
fromRGB
,
RGB
the color to end with
toRGB
,
int
the number of significant red bits, 0 for palette modes
redBits
,
int
the number of significant green bits, 0 for palette modes
greenBits
,
int
the number of significant blue bits, 0 for palette modes
blueBits
)

Creates an ImageData containing one band's worth of a gradient filled block.

pack-priv static void
fillGradientRectangle(GC
the GC to render the gradient onto
gc
,
Device
the device the GC belongs to
device
,
int
the top-left x coordinate of the region to be filled
x
,
int
the top-left y coordinate of the region to be filled
y
,
int
the width of the region to be filled
width
,
int
the height of the region to be filled
height
,
boolean
if true sweeps from top to bottom, else sweeps from left to right
vertical
,
RGB
the color to start with
fromRGB
,
RGB
the color to end with
toRGB
,
int
the number of significant red bits, 0 for palette modes
redBits
,
int
the number of significant green bits, 0 for palette modes
greenBits
,
int
the number of significant blue bits, 0 for palette modes
blueBits
)

Renders a gradient onto a GC.

public int

Returns:

the alpha value at the given coordinates
getAlpha
(int
the x coordinate of the pixel to get the alpha value of
x
,
int
the y coordinate of the pixel to get the alpha value of
y
)

Returns the alpha value at offset x in scanline y in the receiver's alpha data.

public void
getAlphas(int
the x position of the pixel to begin getting alpha values
x
,
int
the y position of the pixel to begin getting alpha values
y
,
int
the width of the data to get
getWidth
,
byte[]
the buffer in which to put the alpha values
alphas
,
int
the offset into the image to begin getting alpha values
startIndex
)

Returns getWidth alpha values starting at offset x in scanline y in the receiver's alpha data starting at startIndex.

pack-priv int

Returns:

MSB_FIRST or LSB_FIRST
getByteOrder
()

Returns the byte order of the receiver.

pack-priv static int
getChannelShift(int mask)

Computes the required channel shift from a mask.

pack-priv static int
getChannelWidth(int mask, int shift)

Computes the required channel width (depth) from a mask.

public int

Returns:

the pixel at the given coordinates
getPixel
(int
the x position of the pixel to get
x
,
int
the y position of the pixel to get
y
)

Returns the pixel value at offset x in scanline y in the receiver's data.

public void
getPixels(int
the x position of the first pixel to get
x
,
int
the y position of the first pixel to get
y
,
int
the width of the data to get
getWidth
,
byte[]
the buffer in which to put the pixels
pixels
,
int
the offset into the byte array to begin storing pixels
startIndex
)

Returns getWidth pixel values starting at offset x in scanline y in the receiver's data starting at startIndex.

public void
getPixels(int
the x position of the first pixel to get
x
,
int
the y position of the first pixel to get
y
,
int
the width of the data to get
getWidth
,
int[]
the buffer in which to put the pixels
pixels
,
int
the offset into the buffer to begin storing pixels
startIndex
)

Returns getWidth pixel values starting at offset x in scanline y in the receiver's data starting at startIndex.

public RGB[]

Returns:

the RGB values for the image or null if direct color
getRGBs
()

Returns an array of RGBs which comprise the indexed color table of the receiver, or null if the receiver has a direct color model.

public ImageData

Returns:

the transparency mask
getTransparencyMask
()

Returns an ImageData which specifies the transparency mask information for the receiver.

pack-priv ImageData
public int

Returns:

the receiver's transparency type
getTransparencyType
()

Returns the image transparency type, which will be one of SWT.TRANSPARENCY_NONE, SWT.TRANSPARENCY_MASK, SWT.TRANSPARENCY_PIXEL or SWT.TRANSPARENCY_ALPHA.

public static ImageData
internal_new(int width, int height, int depth, PaletteData palette, int scanlinePad, byte[] data, int maskPad, byte[] maskData, byte[] alphaData, int alpha, int transparentPixel, int type, int x, int y, int disposalMethod, int delayTime)

Invokes internal SWT functionality to create a new instance of this class.

public ImageData

Returns:

a scaled copy of the image
scaledTo
(int
the width of the new ImageData
width
,
int
the height of the new ImageData
height
)

Returns a copy of the receiver which has been stretched or shrunk to the specified size.

pack-priv void
setAllFields(int width, int height, int depth, int scanlinePad, int bytesPerLine, byte[] data, PaletteData palette, int transparentPixel, byte[] maskData, int maskPad, byte[] alphaData, int alpha, int type, int x, int y, int disposalMethod, int delayTime)

Initializes all fields in the receiver.

public void
setAlpha(int
the x coordinate of the alpha value to set
x
,
int
the y coordinate of the alpha value to set
y
,
int
the value to set the alpha to
alpha
)

Sets the alpha value at offset x in scanline y in the receiver's alpha data.

public void
setAlphas(int
the x coordinate of the pixel to being setting the alpha values
x
,
int
the y coordinate of the pixel to being setting the alpha values
y
,
int
the width of the alpha values to set
putWidth
,
byte[]
the alpha values to set
alphas
,
int
the index at which to begin setting
startIndex
)

Sets the alpha values starting at offset x in scanline y in the receiver's alpha data to the values from the array alphas starting at startIndex.

public void
setPixel(int
the x coordinate of the pixel to set
x
,
int
the y coordinate of the pixel to set
y
,
int
the value to set the pixel to
pixelValue
)

Sets the pixel value at offset x in scanline y in the receiver's data.

public void
setPixels(int
the x position of the pixel to set
x
,
int
the y position of the pixel to set
y
,
int
the width of the pixels to set
putWidth
,
byte[]
the pixels to set
pixels
,
int
the index at which to begin setting
startIndex
)

Sets the pixel values starting at offset x in scanline y in the receiver's data to the values from the array pixels starting at startIndex.

public void
setPixels(int
the x position of the pixel to set
x
,
int
the y position of the pixel to set
y
,
int
the width of the pixels to set
putWidth
,
int[]
the pixels to set
pixels
,
int
the index at which to begin setting
startIndex
)

Sets the pixel values starting at offset x in scanline y in the receiver's data to the values from the array pixels starting at startIndex.

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

alphaback to summary
public int alpha

The global alpha value to be used for every pixel.

If this value is set, the alphaData field is ignored and when the image is rendered each pixel will be blended with the background an amount proportional to this value.

The default is -1 which means 'no global alpha value'

alphaDataback to summary
public byte[] alphaData

The alpha data of the image.

Every pixel can have an alpha blending value that varies from 0, meaning fully transparent, to 255 meaning fully opaque. The number of bytes per scanline is 'width'.

ANY_TO_EIGHTback to summary
pack-priv static final byte[][] ANY_TO_EIGHT

Arbitrary channel width data to 8-bit conversion table.

bytesPerLineback to summary
public int bytesPerLine

The number of bytes per scanline.

This is a multiple of the scanline padding.

databack to summary
public byte[] data

The pixel data of the image.

Note that for 16 bit depth images the pixel data is stored in least significant byte order; however, for 24bit and 32bit depth images the pixel data is stored in most significant byte order.

delayTimeback to summary
public int delayTime

The time to delay before displaying the next image in an animation (this field corresponds to the GIF89a Delay Time value).

depthback to summary
public int depth

The color depth of the image, in bits per pixel.

Note that a depth of 8 or less does not necessarily mean that the image is palette indexed, or conversely that a depth greater than 8 means that the image is direct color. Check the associated PaletteData's isDirect field for such determinations.

disposalMethodback to summary
public int disposalMethod

A description of how to dispose of the current image before displaying the next. It is expressed as one of the following values:

DM_UNSPECIFIED
disposal method not specified
DM_FILL_NONE
do nothing - leave the image in place
DM_FILL_BACKGROUND
fill with the background color
DM_FILL_PREVIOUS
restore the previous picture
(this field corresponds to the GIF89a Disposal Method value)
DITHER_MATRIXback to summary
pack-priv static final int[][] DITHER_MATRIX

Scaled 8x8 Bayer dither matrix.

heightback to summary
public int height

The height of the image, in pixels.

LSB_FIRSTback to summary
pack-priv static final int LSB_FIRST

Byte and bit order constants.

maskDataback to summary
public byte[] maskData

An icon-specific field containing the data from the icon mask.

This is a 1 bit bitmap stored with the most significant bit first. The number of bytes per scanline is '((width + 7) / 8 + (maskPad - 1)) / maskPad * maskPad'.

The default is null which means 'no transparency mask'.

maskPadback to summary
public int maskPad

An icon-specific field containing the scanline pad of the mask.

If one scanline of the transparency mask is not a multiple of this number, it will be padded with zeros until it is.

MSB_FIRSTback to summary
pack-priv static final int MSB_FIRST
paletteback to summary
public PaletteData palette

The color table for the image.

scanlinePadback to summary
public int scanlinePad

The scanline padding.

If one scanline of the image is not a multiple of this number, it will be padded with zeros until it is.

transparentPixelback to summary
public int transparentPixel

The transparent pixel.

Pixels with this value are transparent.

The default is -1 which means 'no transparent pixel'.

typeback to summary
public int type

The type of file from which the image was read. It is expressed as one of the following values:

IMAGE_BMP
Windows BMP file format, no compression
IMAGE_BMP_RLE
Windows BMP file format, RLE compression if appropriate
IMAGE_GIF
GIF file format
IMAGE_ICO
Windows ICO file format
IMAGE_JPEG
JPEG file format
IMAGE_PNG
PNG file format
TYPE_GENERIC_16_LSBback to summary
private static final int TYPE_GENERIC_16_LSB

Data types (internal)

TYPE_GENERIC_16_MSBback to summary
private static final int TYPE_GENERIC_16_MSB

Data types (internal)

TYPE_GENERIC_24back to summary
private static final int TYPE_GENERIC_24

Data types (internal)

TYPE_GENERIC_32_LSBback to summary
private static final int TYPE_GENERIC_32_LSB

Data types (internal)

TYPE_GENERIC_32_MSBback to summary
private static final int TYPE_GENERIC_32_MSB

Data types (internal)

TYPE_GENERIC_8back to summary
private static final int TYPE_GENERIC_8

Data types (internal)

TYPE_INDEX_16_LSBback to summary
private static final int TYPE_INDEX_16_LSB

Data types (internal)

TYPE_INDEX_1_LSBback to summary
private static final int TYPE_INDEX_1_LSB

Data types (internal)

TYPE_INDEX_1_MSBback to summary
private static final int TYPE_INDEX_1_MSB

Data types (internal)

TYPE_INDEX_2back to summary
private static final int TYPE_INDEX_2

Data types (internal)

TYPE_INDEX_4back to summary
private static final int TYPE_INDEX_4

Data types (internal)

TYPE_INDEX_8back to summary
private static final int TYPE_INDEX_8

Data types (internal)

widthback to summary
public int width

The width of the image, in pixels.

xback to summary
public int x

The x coordinate of the top left corner of the image within the logical screen (this field corresponds to the GIF89a Image Left Position value).

yback to summary
public int y

The y coordinate of the top left corner of the image within the logical screen (this field corresponds to the GIF89a Image Top Position value).

Constructor Detail

ImageDataback to summary
public ImageData(int width, int height, int depth, PaletteData palette)

Constructs a new, empty ImageData with the given width, height, depth and palette. The data will be initialized to an (all zero) array of the appropriate size.

Parameters
width:int

the width of the image

height:int

the height of the image

depth:int

the depth of the image

palette:PaletteData

the palette of the image (must not be null)

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_ARGUMENT - if the width or height is zero or negative, or if the depth is not one of 1, 2, 4, 8, 16, 24 or 32
  • ERROR_NULL_ARGUMENT - if the palette is null
ImageDataback to summary
public ImageData(int width, int height, int depth, PaletteData palette, int scanlinePad, byte[] data)

Constructs a new, empty ImageData with the given width, height, depth, palette, scanlinePad and data.

Parameters
width:int

the width of the image

height:int

the height of the image

depth:int

the depth of the image

palette:PaletteData

the palette of the image

scanlinePad:int

the padding of each line, in bytes

data:byte[]

the data of the image

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_ARGUMENT - if the width or height is zero or negative, or if the depth is not one of 1, 2, 4, 8, 16, 24 or 32, or the data array is too small to contain the image data
  • ERROR_NULL_ARGUMENT - if the palette or data is null
  • ERROR_CANNOT_BE_ZERO - if the scanlinePad is zero
ImageDataback to summary
public ImageData(InputStream stream)

Constructs an ImageData loaded from the specified input stream. Throws an error if an error occurs while loading the image, or if the image has an unsupported type. Application code is still responsible for closing the input stream.

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 ImageLoader.load().

This constructor may be used to load a resource as follows:

    static ImageData loadImageData (Class clazz, String string) {
         InputStream stream = clazz.getResourceAsStream (string);
         if (stream == null) return null;
         ImageData imageData = null;
         try {
              imageData = new ImageData (stream);
         } catch (SWTException ex) {
         } finally {
              try {
                   stream.close ();
              } catch (IOException ex) {}
         }
         return imageData;
    }
Parameters
stream:InputStream

the input stream to load the image from (must not be null)

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the stream is null
SWTException:
  • ERROR_IO - if an IO error occurs while reading from the stream
  • ERROR_INVALID_IMAGE - if the image stream contains invalid data
  • ERROR_UNSUPPORTED_FORMAT - if the image stream contains an unrecognized format
See Also
ImageLoader#load(InputStream)
ImageDataback to summary
public ImageData(String filename)

Constructs an ImageData loaded from a file with the specified name. Throws an error if an error occurs loading the image, or if the image has an unsupported type.

This constructor is provided for convenience when loading a single image only. If the file contains multiple images, only the first one will be loaded. To load multiple images, use ImageLoader.load().

Parameters
filename:String

the name of the file to load the image from (must not be null)

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the file name is null
SWTException:
  • ERROR_IO - if an IO error occurs while reading from the file
  • ERROR_INVALID_IMAGE - if the image file contains invalid data
  • ERROR_UNSUPPORTED_FORMAT - if the image file contains an unrecognized format
ImageDataback to summary
pack-priv ImageData()

Prevents uninitialized instances from being created outside the package.

ImageDataback to summary
pack-priv ImageData(int width, int height, int depth, PaletteData palette, int scanlinePad, byte[] data, int maskPad, byte[] maskData, byte[] alphaData, int alpha, int transparentPixel, int type, int x, int y, int disposalMethod, int delayTime)

Constructs an image data by giving values for all non-computable fields.

This method is for internal use, and is not described further.

Method Detail

blitback to summary
pack-priv static void blit(byte[] srcData, int srcDepth, int srcStride, int srcOrder, int srcWidth, int srcHeight, int srcRedMask, int srcGreenMask, int srcBlueMask, byte[] destData, int destDepth, int destStride, int destOrder, int destWidth, int destHeight, int destRedMask, int destGreenMask, int destBlueMask, boolean flipX, boolean flipY)

Blits a direct palette image into a direct palette image.

Note

When the source and destination depth, order and masks are pairwise equal and the blitter operation is BLIT_SRC, the masks are ignored. Hence when not changing the image data format, 0 may be specified for the masks.

Parameters
srcData:byte[]

the source byte array containing image data

srcDepth:int

the source depth: one of 8, 16, 24, 32

srcStride:int

the source number of bytes per line

srcOrder:int

the source byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if srcDepth is not 16 or 32

srcWidth:int

the width of the source blit region

srcHeight:int

the height of the source blit region

srcRedMask:int

the source red channel mask

srcGreenMask:int

the source green channel mask

srcBlueMask:int

the source blue channel mask

destData:byte[]

the destination byte array containing image data

destDepth:int

the destination depth: one of 8, 16, 24, 32

destStride:int

the destination number of bytes per line

destOrder:int

the destination byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if destDepth is not 16 or 32

destWidth:int

the width of the destination blit region

destHeight:int

the height of the destination blit region

destRedMask:int

the destination red channel mask

destGreenMask:int

the destination green channel mask

destBlueMask:int

the destination blue channel mask

flipX:boolean

if true the resulting image is flipped along the vertical axis

flipY:boolean

if true the resulting image is flipped along the horizontal axis

blitback to summary
pack-priv static void blit(byte[] srcData, int srcDepth, int srcStride, int srcOrder, int srcWidth, int srcHeight, byte[] destData, int destDepth, int destStride, int destOrder, int destWidth, int destHeight, boolean flipX, boolean flipY)

Blits an index palette image into an index palette image.

Note

The source and destination red, green, and blue arrays may be null if no alpha blending or dither is to be performed.

Parameters
srcData:byte[]

the source byte array containing image data

srcDepth:int

the source depth: one of 1, 2, 4, 8

srcStride:int

the source number of bytes per line

srcOrder:int

the source byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if srcDepth is not 1

srcWidth:int

the width of the source blit region

srcHeight:int

the height of the source blit region

destData:byte[]

the destination byte array containing image data

destDepth:int

the destination depth: one of 1, 2, 4, 8

destStride:int

the destination number of bytes per line

destOrder:int

the destination byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if destDepth is not 1

destWidth:int

the width of the destination blit region

destHeight:int

the height of the destination blit region

flipX:boolean

if true the resulting image is flipped along the vertical axis

flipY:boolean

if true the resulting image is flipped along the horizontal axis

blitback to summary
pack-priv static void blit(int srcWidth, int srcHeight, byte[] srcData, int srcDepth, int srcStride, int srcOrder, byte[] srcReds, byte[] srcGreens, byte[] srcBlues, byte[] destData, int destDepth, int destStride, int destOrder, int destRedMask, int destGreenMask, int destBlueMask)

Blits an index palette image into a direct palette image.

Note

The source and destination masks and palettes must always be fully specified.

Parameters
srcWidth:int

the width of the source blit region

srcHeight:int

the height of the source blit region

srcData:byte[]

the source byte array containing image data

srcDepth:int

the source depth: one of 1, 2, 4, 8

srcStride:int

the source number of bytes per line

srcOrder:int

the source byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if srcDepth is not 1

srcReds:byte[]

the source palette red component intensities

srcGreens:byte[]

the source palette green component intensities

srcBlues:byte[]

the source palette blue component intensities

destData:byte[]

the destination byte array containing image data

destDepth:int

the destination depth: one of 8, 16, 24, 32

destStride:int

the destination number of bytes per line

destOrder:int

the destination byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if destDepth is not 16 or 32

destRedMask:int

the destination red channel mask

destGreenMask:int

the destination green channel mask

destBlueMask:int

the destination blue channel mask

buildDitheredGradientChannelback to summary
pack-priv static void buildDitheredGradientChannel(int from, int to, int steps, int bandWidth, int bandHeight, boolean vertical, byte[] bitmapData, int dp, int bytesPerLine, int bits)
buildPreciseGradientChannelback to summary
pack-priv static void buildPreciseGradientChannel(int from, int to, int steps, int bandWidth, int bandHeight, boolean vertical, byte[] bitmapData, int dp, int bytesPerLine)
bwPaletteback to summary
pack-priv static PaletteData bwPalette()

Returns a palette with 2 colors: black & white.

checkDataback to summary
pack-priv static byte[] checkData(byte[] data)
cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Returns a new instance of the same class as the receiver, whose slots have been filled in with copies of the values in the slots of the receiver. That is, the returned object is a deep copy of the receiver.

Returns:Object

a copy of the receiver.

Annotations
@Override
colorMaskImageback to summary
pack-priv ImageData colorMaskImage(int pixel)
convertMaskback to summary
pack-priv static ImageData convertMask(ImageData mask)
convertPadback to summary
pack-priv static byte[] convertPad(byte[] data, int width, int height, int depth, int pad, int newPad)
createGradientBandback to summary
pack-priv static ImageData createGradientBand(int width, int height, boolean vertical, RGB fromRGB, RGB toRGB, int redBits, int greenBits, int blueBits)

Creates an ImageData containing one band's worth of a gradient filled block. If vertical is true, the band must be tiled horizontally to fill a region, otherwise it must be tiled vertically.

Parameters
width:int

the width of the region to be filled

height:int

the height of the region to be filled

vertical:boolean

if true sweeps from top to bottom, else sweeps from left to right

fromRGB:RGB

the color to start with

toRGB:RGB

the color to end with

redBits:int

the number of significant red bits, 0 for palette modes

greenBits:int

the number of significant green bits, 0 for palette modes

blueBits:int

the number of significant blue bits, 0 for palette modes

Returns:ImageData

the new ImageData

fillGradientRectangleback to summary
pack-priv static void fillGradientRectangle(GC gc, Device device, int x, int y, int width, int height, boolean vertical, RGB fromRGB, RGB toRGB, int redBits, int greenBits, int blueBits)

Renders a gradient onto a GC.

This is a GC helper.

Parameters
gc:GC

the GC to render the gradient onto

device:Device

the device the GC belongs to

x:int

the top-left x coordinate of the region to be filled

y:int

the top-left y coordinate of the region to be filled

width:int

the width of the region to be filled

height:int

the height of the region to be filled

vertical:boolean

if true sweeps from top to bottom, else sweeps from left to right

fromRGB:RGB

the color to start with

toRGB:RGB

the color to end with

redBits:int

the number of significant red bits, 0 for palette modes

greenBits:int

the number of significant green bits, 0 for palette modes

blueBits:int

the number of significant blue bits, 0 for palette modes

getAlphaback to summary
public int getAlpha(int x, int y)

Returns the alpha value at offset x in scanline y in the receiver's alpha data. The alpha value is between 0 (transparent) and 255 (opaque).

Parameters
x:int

the x coordinate of the pixel to get the alpha value of

y:int

the y coordinate of the pixel to get the alpha value of

Returns:int

the alpha value at the given coordinates

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_ARGUMENT - if either argument is out of range
getAlphasback to summary
public void getAlphas(int x, int y, int getWidth, byte[] alphas, int startIndex)

Returns getWidth alpha values starting at offset x in scanline y in the receiver's alpha data starting at startIndex. The alpha values are unsigned, between (byte)0 (transparent) and (byte)255 (opaque).

Parameters
x:int

the x position of the pixel to begin getting alpha values

y:int

the y position of the pixel to begin getting alpha values

getWidth:int

the width of the data to get

alphas:byte[]

the buffer in which to put the alpha values

startIndex:int

the offset into the image to begin getting alpha values

Exceptions
IndexOutOfBoundsException:
if getWidth is too large
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if pixels is null
  • ERROR_INVALID_ARGUMENT - if x or y is out of bounds
  • ERROR_INVALID_ARGUMENT - if getWidth is negative
getByteOrderback to summary
pack-priv int getByteOrder()

Returns the byte order of the receiver.

Returns:int

MSB_FIRST or LSB_FIRST

getChannelShiftback to summary
pack-priv static int getChannelShift(int mask)

Computes the required channel shift from a mask.

getChannelWidthback to summary
pack-priv static int getChannelWidth(int mask, int shift)

Computes the required channel width (depth) from a mask.

getPixelback to summary
public int getPixel(int x, int y)

Returns the pixel value at offset x in scanline y in the receiver's data.

Parameters
x:int

the x position of the pixel to get

y:int

the y position of the pixel to get

Returns:int

the pixel at the given coordinates

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_ARGUMENT - if either argument is out of bounds
SWTException:
  • ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32
getPixelsback to summary
public void getPixels(int x, int y, int getWidth, byte[] pixels, int startIndex)

Returns getWidth pixel values starting at offset x in scanline y in the receiver's data starting at startIndex.

Parameters
x:int

the x position of the first pixel to get

y:int

the y position of the first pixel to get

getWidth:int

the width of the data to get

pixels:byte[]

the buffer in which to put the pixels

startIndex:int

the offset into the byte array to begin storing pixels

Exceptions
IndexOutOfBoundsException:
if getWidth is too large
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if pixels is null
  • ERROR_INVALID_ARGUMENT - if x or y is out of bounds
  • ERROR_INVALID_ARGUMENT - if getWidth is negative
SWTException:
  • ERROR_UNSUPPORTED_DEPTH - if the depth is not one of 1, 2, 4 or 8 (For higher depths, use the int[] version of this method.)
getPixelsback to summary
public void getPixels(int x, int y, int getWidth, int[] pixels, int startIndex)

Returns getWidth pixel values starting at offset x in scanline y in the receiver's data starting at startIndex.

Parameters
x:int

the x position of the first pixel to get

y:int

the y position of the first pixel to get

getWidth:int

the width of the data to get

pixels:int[]

the buffer in which to put the pixels

startIndex:int

the offset into the buffer to begin storing pixels

Exceptions
IndexOutOfBoundsException:
if getWidth is too large
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if pixels is null
  • ERROR_INVALID_ARGUMENT - if x or y is out of bounds
  • ERROR_INVALID_ARGUMENT - if getWidth is negative
SWTException:
  • ERROR_UNSUPPORTED_DEPTH - if the depth is not one of 1, 2, 4, 8, 16, 24 or 32
getRGBsback to summary
public RGB[] getRGBs()

Returns an array of RGBs which comprise the indexed color table of the receiver, or null if the receiver has a direct color model.

Returns:RGB[]

the RGB values for the image or null if direct color

See Also
PaletteData#getRGBs()
getTransparencyMaskback to summary
public ImageData getTransparencyMask()

Returns an ImageData which specifies the transparency mask information for the receiver. If the receiver has no transparency or is not an icon, returns an opaque mask.

Returns:ImageData

the transparency mask

getTransparencyMaskFromAlphaDataback to summary
pack-priv ImageData getTransparencyMaskFromAlphaData()
getTransparencyTypeback to summary
public int getTransparencyType()

Returns the image transparency type, which will be one of SWT.TRANSPARENCY_NONE, SWT.TRANSPARENCY_MASK, SWT.TRANSPARENCY_PIXEL or SWT.TRANSPARENCY_ALPHA.

Returns:int

the receiver's transparency type

internal_newback to summary
public static ImageData internal_new(int width, int height, int depth, PaletteData palette, int scanlinePad, byte[] data, int maskPad, byte[] maskData, byte[] alphaData, int alpha, int transparentPixel, int type, int x, int y, int disposalMethod, int delayTime)

Invokes internal SWT functionality to create a new instance of this class.

Important Note

This method is not part of the public API for ImageData. It is marked public only so that it can be shared within the packages provided by SWT. It is subject to change without notice, and should never be called from application code.

This method is for internal use, and is not described further.

scaledToback to summary
public ImageData scaledTo(int width, int height)

Returns a copy of the receiver which has been stretched or shrunk to the specified size. If either the width or height is negative, the resulting image will be inverted in the associated axis.

Parameters
width:int

the width of the new ImageData

height:int

the height of the new ImageData

Returns:ImageData

a scaled copy of the image

setAllFieldsback to summary
pack-priv void setAllFields(int width, int height, int depth, int scanlinePad, int bytesPerLine, byte[] data, PaletteData palette, int transparentPixel, byte[] maskData, int maskPad, byte[] alphaData, int alpha, int type, int x, int y, int disposalMethod, int delayTime)

Initializes all fields in the receiver. This method must be called by all public constructors to ensure that all fields are initialized for a new ImageData object. If a new field is added to the class, then it must be added to this method.

This method is for internal use, and is not described further.

setAlphaback to summary
public void setAlpha(int x, int y, int alpha)

Sets the alpha value at offset x in scanline y in the receiver's alpha data. The alpha value must be between 0 (transparent) and 255 (opaque).

Parameters
x:int

the x coordinate of the alpha value to set

y:int

the y coordinate of the alpha value to set

alpha:int

the value to set the alpha to

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_ARGUMENT - if x or y is out of bounds
setAlphasback to summary
public void setAlphas(int x, int y, int putWidth, byte[] alphas, int startIndex)

Sets the alpha values starting at offset x in scanline y in the receiver's alpha data to the values from the array alphas starting at startIndex. The alpha values must be between (byte)0 (transparent) and (byte)255 (opaque)

Parameters
x:int

the x coordinate of the pixel to being setting the alpha values

y:int

the y coordinate of the pixel to being setting the alpha values

putWidth:int

the width of the alpha values to set

alphas:byte[]

the alpha values to set

startIndex:int

the index at which to begin setting

Exceptions
IndexOutOfBoundsException:
if putWidth is too large
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if pixels is null
  • ERROR_INVALID_ARGUMENT - if x or y is out of bounds
  • ERROR_INVALID_ARGUMENT - if putWidth is negative
setPixelback to summary
public void setPixel(int x, int y, int pixelValue)

Sets the pixel value at offset x in scanline y in the receiver's data.

Parameters
x:int

the x coordinate of the pixel to set

y:int

the y coordinate of the pixel to set

pixelValue:int

the value to set the pixel to

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_ARGUMENT - if x or y is out of bounds
SWTException:
  • ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32
setPixelsback to summary
public void setPixels(int x, int y, int putWidth, byte[] pixels, int startIndex)

Sets the pixel values starting at offset x in scanline y in the receiver's data to the values from the array pixels starting at startIndex.

Parameters
x:int

the x position of the pixel to set

y:int

the y position of the pixel to set

putWidth:int

the width of the pixels to set

pixels:byte[]

the pixels to set

startIndex:int

the index at which to begin setting

Exceptions
IndexOutOfBoundsException:
if putWidth is too large
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if pixels is null
  • ERROR_INVALID_ARGUMENT - if x or y is out of bounds
  • ERROR_INVALID_ARGUMENT - if putWidth is negative
SWTException:
  • ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8 (For higher depths, use the int[] version of this method.)
setPixelsback to summary
public void setPixels(int x, int y, int putWidth, int[] pixels, int startIndex)

Sets the pixel values starting at offset x in scanline y in the receiver's data to the values from the array pixels starting at startIndex.

Parameters
x:int

the x position of the pixel to set

y:int

the y position of the pixel to set

putWidth:int

the width of the pixels to set

pixels:int[]

the pixels to set

startIndex:int

the index at which to begin setting

Exceptions
IndexOutOfBoundsException:
if putWidth is too large
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if pixels is null
  • ERROR_INVALID_ARGUMENT - if x or y is out of bounds
  • ERROR_INVALID_ARGUMENT - if putWidth is negative
SWTException:
  • ERROR_UNSUPPORTED_DEPTH if the depth is not one of 1, 2, 4, 8, 16, 24 or 32