Class ImageData
- All Implemented Interfaces:
Cloneable
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionintThe global alpha value to be used for every pixel.byte[]The alpha data of the image.(package private) static final byte[][]Arbitrary channel width data to 8-bit conversion table.intThe number of bytes per scanline.byte[]The pixel data of the image.intThe time to delay before displaying the next image in an animation (this field corresponds to the GIF89a Delay Time value).intThe color depth of the image, in bits per pixel.intA description of how to dispose of the current image before displaying the next.(package private) static final int[][]Scaled 8x8 Bayer dither matrix.intThe height of the image, in pixels.(package private) static final intByte and bit order constants.byte[]An icon-specific field containing the data from the icon mask.intAn icon-specific field containing the scanline pad of the mask.(package private) static final intThe color table for the image.intThe scanline padding.intThe transparent pixel.intThe type of file from which the image was read.private static final intData types (internal)private static final intData types (internal)private static final intData types (internal)private static final intData types (internal)private static final intData types (internal)private static final intData types (internal)private static final intData types (internal)private static final intData types (internal)private static final intData types (internal)private static final intData types (internal)private static final intData types (internal)private static final intData types (internal)intThe width of the image, in pixels.intThe x coordinate of the top left corner of the image within the logical screen (this field corresponds to the GIF89a Image Left Position value).intThe 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
ConstructorsConstructorDescriptionPrevents uninitialized instances from being created outside the package.ImageData(int width, int height, int depth, PaletteData palette) Constructs a new, empty ImageData with the given width, height, depth and palette.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.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.ImageData(InputStream stream) Constructs anImageDataloaded from the specified input stream.Constructs anImageDataloaded from a file with the specified name. -
Method Summary
Modifier and TypeMethodDescription(package private) static voidblit(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.(package private) static voidblit(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.(package private) static voidblit(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.(package private) static voidbuildDitheredGradientChannel(int from, int to, int steps, int bandWidth, int bandHeight, boolean vertical, byte[] bitmapData, int dp, int bytesPerLine, int bits) (package private) static voidbuildPreciseGradientChannel(int from, int to, int steps, int bandWidth, int bandHeight, boolean vertical, byte[] bitmapData, int dp, int bytesPerLine) (package private) static PaletteDataReturns a palette with 2 colors: black invalid input: '&' white.(package private) static byte[]checkData(byte[] data) 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.(package private) ImageDatacolorMaskImage(int pixel) (package private) static ImageDataconvertMask(ImageData mask) (package private) static byte[]convertPad(byte[] data, int width, int height, int depth, int pad, int newPad) (package private) static ImageDatacreateGradientBand(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.(package private) static voidfillGradientRectangle(GC gc, Device device, int x, int y, int width, int height, boolean vertical, RGB fromRGB, RGB toRGB, int redBits, int greenBits, int blueBits, int zoom) Renders a gradient onto a GC.intgetAlpha(int x, int y) Returns the alpha value at offsetxin scanlineyin the receiver's alpha data.voidgetAlphas(int x, int y, int getWidth, byte[] alphas, int startIndex) ReturnsgetWidthalpha values starting at offsetxin scanlineyin the receiver's alpha data starting atstartIndex.(package private) intReturns the byte order of the receiver.(package private) static intgetChannelShift(int mask) Computes the required channel shift from a mask.(package private) static intgetChannelWidth(int mask, int shift) Computes the required channel width (depth) from a mask.intgetPixel(int x, int y) Returns the pixel value at offsetxin scanlineyin the receiver's data.voidgetPixels(int x, int y, int getWidth, byte[] pixels, int startIndex) ReturnsgetWidthpixel values starting at offsetxin scanlineyin the receiver's data starting atstartIndex.voidgetPixels(int x, int y, int getWidth, int[] pixels, int startIndex) ReturnsgetWidthpixel values starting at offsetxin scanlineyin the receiver's data starting atstartIndex.RGB[]getRGBs()Returns an array ofRGBs which comprise the indexed color table of the receiver, or null if the receiver has a direct color model.Returns anImageDatawhich specifies the transparency mask information for the receiver.(package private) ImageDataintReturns the image transparency type, which will be one ofSWT.TRANSPARENCY_NONE,SWT.TRANSPARENCY_MASK,SWT.TRANSPARENCY_PIXELorSWT.TRANSPARENCY_ALPHA.static ImageDatainternal_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.scaledTo(int width, int height) Returns a copy of the receiver which has been stretched or shrunk to the specified size.(package private) voidsetAllFields(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.voidsetAlpha(int x, int y, int alpha) Sets the alpha value at offsetxin scanlineyin the receiver's alpha data.voidsetAlphas(int x, int y, int putWidth, byte[] alphas, int startIndex) Sets the alpha values starting at offsetxin scanlineyin the receiver's alpha data to the values from the arrayalphasstarting atstartIndex.voidsetPixel(int x, int y, int pixelValue) Sets the pixel value at offsetxin scanlineyin the receiver's data.voidsetPixels(int x, int y, int putWidth, byte[] pixels, int startIndex) Sets the pixel values starting at offsetxin scanlineyin the receiver's data to the values from the arraypixelsstarting atstartIndex.voidsetPixels(int x, int y, int putWidth, int[] pixels, int startIndex) Sets the pixel values starting at offsetxin scanlineyin the receiver's data to the values from the arraypixelsstarting atstartIndex.
-
Field Details
-
width
public int widthThe width of the image, in pixels. -
height
public int heightThe height of the image, in pixels. -
depth
public int depthThe 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.
-
scanlinePad
public int scanlinePadThe scanline padding.If one scanline of the image is not a multiple of this number, it will be padded with zeros until it is.
-
bytesPerLine
public int bytesPerLineThe number of bytes per scanline.This is a multiple of the scanline padding.
-
data
public byte[] dataThe 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.
-
palette
The color table for the image. -
transparentPixel
public int transparentPixelThe transparent pixel.Pixels with this value are transparent.
The default is -1 which means 'no transparent pixel'.
-
maskData
public byte[] maskDataAn 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'.
-
maskPad
public int maskPadAn 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.
-
alphaData
public byte[] alphaDataThe 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'.
-
alpha
public int alphaThe global alpha value to be used for every pixel.If this value is set, the
alphaDatafield 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'
-
type
public int typeThe 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
-
x
public int xThe x coordinate of the top left corner of the image within the logical screen (this field corresponds to the GIF89a Image Left Position value). -
y
public int yThe y coordinate of the top left corner of the image within the logical screen (this field corresponds to the GIF89a Image Top Position value). -
disposalMethod
public int disposalMethodA 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
-
delayTime
public int delayTimeThe time to delay before displaying the next image in an animation (this field corresponds to the GIF89a Delay Time value). -
ANY_TO_EIGHT
static final byte[][] ANY_TO_EIGHTArbitrary channel width data to 8-bit conversion table. -
DITHER_MATRIX
static final int[][] DITHER_MATRIXScaled 8x8 Bayer dither matrix. -
LSB_FIRST
static final int LSB_FIRSTByte and bit order constants.- See Also:
-
MSB_FIRST
static final int MSB_FIRST- See Also:
-
TYPE_GENERIC_8
private static final int TYPE_GENERIC_8Data types (internal)- See Also:
-
TYPE_GENERIC_16_MSB
private static final int TYPE_GENERIC_16_MSBData types (internal)- See Also:
-
TYPE_GENERIC_16_LSB
private static final int TYPE_GENERIC_16_LSBData types (internal)- See Also:
-
TYPE_GENERIC_24
private static final int TYPE_GENERIC_24Data types (internal)- See Also:
-
TYPE_GENERIC_32_MSB
private static final int TYPE_GENERIC_32_MSBData types (internal)- See Also:
-
TYPE_GENERIC_32_LSB
private static final int TYPE_GENERIC_32_LSBData types (internal)- See Also:
-
TYPE_INDEX_16_LSB
private static final int TYPE_INDEX_16_LSBData types (internal)- See Also:
-
TYPE_INDEX_8
private static final int TYPE_INDEX_8Data types (internal)- See Also:
-
TYPE_INDEX_4
private static final int TYPE_INDEX_4Data types (internal)- See Also:
-
TYPE_INDEX_2
private static final int TYPE_INDEX_2Data types (internal)- See Also:
-
TYPE_INDEX_1_MSB
private static final int TYPE_INDEX_1_MSBData types (internal)- See Also:
-
TYPE_INDEX_1_LSB
private static final int TYPE_INDEX_1_LSBData types (internal)- See Also:
-
-
Constructor Details
-
ImageData
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- the width of the imageheight- the height of the imagedepth- the depth of the imagepalette- the palette of the image (must not be null)- Throws:
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
-
ImageData
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- the width of the imageheight- the height of the imagedepth- the depth of the imagepalette- the palette of the imagescanlinePad- the padding of each line, in bytesdata- the data of the image- Throws:
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
-
ImageData
Constructs anImageDataloaded 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- the input stream to load the image from (must not be null)- Throws:
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:
-
ImageData
Constructs anImageDataloaded 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- the name of the file to load the image from (must not be null)- Throws:
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
-
ImageData
ImageData()Prevents uninitialized instances from being created outside the package. -
ImageData
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 Details
-
setAllFields
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.
-
internal_new
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: 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.
-
colorMaskImage
-
checkData
static byte[] checkData(byte[] data) -
clone
-
getAlpha
public int getAlpha(int x, int y) Returns the alpha value at offsetxin scanlineyin the receiver's alpha data. The alpha value is between 0 (transparent) and 255 (opaque).- Parameters:
x- the x coordinate of the pixel to get the alpha value ofy- the y coordinate of the pixel to get the alpha value of- Returns:
- the alpha value at the given coordinates
- Throws:
IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if either argument is out of range
-
getAlphas
public void getAlphas(int x, int y, int getWidth, byte[] alphas, int startIndex) ReturnsgetWidthalpha values starting at offsetxin scanlineyin the receiver's alpha data starting atstartIndex. The alpha values are unsigned, between(byte)0(transparent) and(byte)255(opaque).- Parameters:
x- the x position of the pixel to begin getting alpha valuesy- the y position of the pixel to begin getting alpha valuesgetWidth- the width of the data to getalphas- the buffer in which to put the alpha valuesstartIndex- the offset into the image to begin getting alpha values- Throws:
IndexOutOfBoundsException- if getWidth is too largeIllegalArgumentException-- 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
-
getPixel
public int getPixel(int x, int y) Returns the pixel value at offsetxin scanlineyin the receiver's data.- Parameters:
x- the x position of the pixel to gety- the y position of the pixel to get- Returns:
- the pixel at the given coordinates
- Throws:
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
-
getPixels
public void getPixels(int x, int y, int getWidth, byte[] pixels, int startIndex) ReturnsgetWidthpixel values starting at offsetxin scanlineyin the receiver's data starting atstartIndex.- Parameters:
x- the x position of the first pixel to gety- the y position of the first pixel to getgetWidth- the width of the data to getpixels- the buffer in which to put the pixelsstartIndex- the offset into the byte array to begin storing pixels- Throws:
IndexOutOfBoundsException- if getWidth is too largeIllegalArgumentException-- 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.)
-
getPixels
public void getPixels(int x, int y, int getWidth, int[] pixels, int startIndex) ReturnsgetWidthpixel values starting at offsetxin scanlineyin the receiver's data starting atstartIndex.- Parameters:
x- the x position of the first pixel to gety- the y position of the first pixel to getgetWidth- the width of the data to getpixels- the buffer in which to put the pixelsstartIndex- the offset into the buffer to begin storing pixels- Throws:
IndexOutOfBoundsException- if getWidth is too largeIllegalArgumentException-- 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
-
getRGBs
Returns an array ofRGBs which comprise the indexed color table of the receiver, or null if the receiver has a direct color model.- Returns:
- the RGB values for the image or null if direct color
- See Also:
-
getTransparencyMask
Returns anImageDatawhich specifies the transparency mask information for the receiver. If the receiver has no transparency or is not an icon, returns an opaque mask.- Returns:
- the transparency mask
-
getTransparencyMaskFromAlphaData
ImageData getTransparencyMaskFromAlphaData() -
getTransparencyType
public int getTransparencyType()Returns the image transparency type, which will be one ofSWT.TRANSPARENCY_NONE,SWT.TRANSPARENCY_MASK,SWT.TRANSPARENCY_PIXELorSWT.TRANSPARENCY_ALPHA.- Returns:
- the receiver's transparency type
-
getByteOrder
int getByteOrder()Returns the byte order of the receiver.- Returns:
- MSB_FIRST or LSB_FIRST
-
scaledTo
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- the width of the new ImageDataheight- the height of the new ImageData- Returns:
- a scaled copy of the image
-
setAlpha
public void setAlpha(int x, int y, int alpha) Sets the alpha value at offsetxin scanlineyin the receiver's alpha data. The alpha value must be between 0 (transparent) and 255 (opaque).- Parameters:
x- the x coordinate of the alpha value to sety- the y coordinate of the alpha value to setalpha- the value to set the alpha to- Throws:
IllegalArgumentException-- ERROR_INVALID_ARGUMENT - if x or y is out of bounds
-
setAlphas
public void setAlphas(int x, int y, int putWidth, byte[] alphas, int startIndex) Sets the alpha values starting at offsetxin scanlineyin the receiver's alpha data to the values from the arrayalphasstarting atstartIndex. The alpha values must be between(byte)0(transparent) and(byte)255(opaque)- Parameters:
x- the x coordinate of the pixel to being setting the alpha valuesy- the y coordinate of the pixel to being setting the alpha valuesputWidth- the width of the alpha values to setalphas- the alpha values to setstartIndex- the index at which to begin setting- Throws:
IndexOutOfBoundsException- if putWidth is too largeIllegalArgumentException-- 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
-
setPixel
public void setPixel(int x, int y, int pixelValue) Sets the pixel value at offsetxin scanlineyin the receiver's data.- Parameters:
x- the x coordinate of the pixel to sety- the y coordinate of the pixel to setpixelValue- the value to set the pixel to- Throws:
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
-
setPixels
public void setPixels(int x, int y, int putWidth, byte[] pixels, int startIndex) Sets the pixel values starting at offsetxin scanlineyin the receiver's data to the values from the arraypixelsstarting atstartIndex.- Parameters:
x- the x position of the pixel to sety- the y position of the pixel to setputWidth- the width of the pixels to setpixels- the pixels to setstartIndex- the index at which to begin setting- Throws:
IndexOutOfBoundsException- if putWidth is too largeIllegalArgumentException-- 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.)
-
setPixels
public void setPixels(int x, int y, int putWidth, int[] pixels, int startIndex) Sets the pixel values starting at offsetxin scanlineyin the receiver's data to the values from the arraypixelsstarting atstartIndex.- Parameters:
x- the x position of the pixel to sety- the y position of the pixel to setputWidth- the width of the pixels to setpixels- the pixels to setstartIndex- the index at which to begin setting- Throws:
IndexOutOfBoundsException- if putWidth is too largeIllegalArgumentException-- 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
-
bwPalette
Returns a palette with 2 colors: black invalid input: '&' white. -
convertMask
-
convertPad
static byte[] convertPad(byte[] data, int width, int height, int depth, int pad, int newPad) -
blit
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- the source byte array containing image datasrcDepth- the source depth: one of 8, 16, 24, 32srcStride- the source number of bytes per linesrcOrder- the source byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if srcDepth is not 16 or 32srcWidth- the width of the source blit regionsrcHeight- the height of the source blit regionsrcRedMask- the source red channel masksrcGreenMask- the source green channel masksrcBlueMask- the source blue channel maskdestData- the destination byte array containing image datadestDepth- the destination depth: one of 8, 16, 24, 32destStride- the destination number of bytes per linedestOrder- the destination byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if destDepth is not 16 or 32destWidth- the width of the destination blit regiondestHeight- the height of the destination blit regiondestRedMask- the destination red channel maskdestGreenMask- the destination green channel maskdestBlueMask- the destination blue channel maskflipX- if true the resulting image is flipped along the vertical axisflipY- if true the resulting image is flipped along the horizontal axis
-
blit
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- the source byte array containing image datasrcDepth- the source depth: one of 1, 2, 4, 8srcStride- the source number of bytes per linesrcOrder- the source byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if srcDepth is not 1srcWidth- the width of the source blit regionsrcHeight- the height of the source blit regiondestData- the destination byte array containing image datadestDepth- the destination depth: one of 1, 2, 4, 8destStride- the destination number of bytes per linedestOrder- the destination byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if destDepth is not 1destWidth- the width of the destination blit regiondestHeight- the height of the destination blit regionflipX- if true the resulting image is flipped along the vertical axisflipY- if true the resulting image is flipped along the horizontal axis
-
blit
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- the width of the source blit regionsrcHeight- the height of the source blit regionsrcData- the source byte array containing image datasrcDepth- the source depth: one of 1, 2, 4, 8srcStride- the source number of bytes per linesrcOrder- the source byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if srcDepth is not 1srcReds- the source palette red component intensitiessrcGreens- the source palette green component intensitiessrcBlues- the source palette blue component intensitiesdestData- the destination byte array containing image datadestDepth- the destination depth: one of 8, 16, 24, 32destStride- the destination number of bytes per linedestOrder- the destination byte ordering: one of MSB_FIRST or LSB_FIRST; ignored if destDepth is not 16 or 32destRedMask- the destination red channel maskdestGreenMask- the destination green channel maskdestBlueMask- the destination blue channel mask
-
getChannelShift
static int getChannelShift(int mask) Computes the required channel shift from a mask. -
getChannelWidth
static int getChannelWidth(int mask, int shift) Computes the required channel width (depth) from a mask. -
createGradientBand
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. Ifverticalis true, the band must be tiled horizontally to fill a region, otherwise it must be tiled vertically.- Parameters:
width- the width of the region to be filledheight- the height of the region to be filledvertical- if true sweeps from top to bottom, else sweeps from left to rightfromRGB- the color to start withtoRGB- the color to end withredBits- the number of significant red bits, 0 for palette modesgreenBits- the number of significant green bits, 0 for palette modesblueBits- the number of significant blue bits, 0 for palette modes- Returns:
- the new ImageData
-
buildPreciseGradientChannel
static void buildPreciseGradientChannel(int from, int to, int steps, int bandWidth, int bandHeight, boolean vertical, byte[] bitmapData, int dp, int bytesPerLine) -
buildDitheredGradientChannel
static void buildDitheredGradientChannel(int from, int to, int steps, int bandWidth, int bandHeight, boolean vertical, byte[] bitmapData, int dp, int bytesPerLine, int bits) -
fillGradientRectangle
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, int zoom) Renders a gradient onto a GC.This is a GC helper.
- Parameters:
gc- the GC to render the gradient ontodevice- the device the GC belongs tox- the top-left x coordinate of the region to be filledy- the top-left y coordinate of the region to be filledwidth- the width of the region to be filledheight- the height of the region to be filledvertical- if true sweeps from top to bottom, else sweeps from left to rightfromRGB- the color to start withtoRGB- the color to end withredBits- the number of significant red bits, 0 for palette modesgreenBits- the number of significant green bits, 0 for palette modesblueBits- the number of significant blue bits, 0 for palette modeszoom- the zoom of gc drawer used
-