Draw2D v2.0

org.eclipse.draw2d.util
Class ImageDataHelper

java.lang.Object
  |
  +--org.eclipse.draw2d.util.ImageDataHelper

public class ImageDataHelper
extends Object

This class provides some static helper methods for manipulating the SWT ImageData in special ways that are not provided by the image data itself.


Constructor Summary
ImageDataHelper()
           
 
Method Summary
static int getNearestColorIndex(int red, int green, int blue, RGB[] colors)
          Answer the nearest color index to the RGB color passed in from the color array.
static void getPixels(ImageData imageData, int x, int y, int width, int[] pixelRow)
          getPixels: getPixels into int array.
static ImageData mixAlphaWithinRegion(ImageData fromImageData, Region region, double alpha, RGB backColor)
          mixAlphaWithinRegion: Mix in the alpha value using the given background color within the region specified.
static void setPixels(ImageData dest, int x, int y, int putWidth, int[] pixels, int startIndex)
          This method doesn't appear on ImageData, but it should.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageDataHelper

public ImageDataHelper()
Method Detail

getNearestColorIndex

public static int getNearestColorIndex(int red,
                                       int green,
                                       int blue,
                                       RGB[] colors)
Answer the nearest color index to the RGB color passed in from the color array.

getPixels

public static void getPixels(ImageData imageData,
                             int x,
                             int y,
                             int width,
                             int[] pixelRow)
getPixels: getPixels into int array. This should be done in ImageData, but they don't have that yet.

mixAlphaWithinRegion

public static ImageData mixAlphaWithinRegion(ImageData fromImageData,
                                             Region region,
                                             double alpha,
                                             RGB backColor)
mixAlphaWithinRegion: Mix in the alpha value using the given background color within the region specified. Answer the new mixed in ImageData

setPixels

public static void setPixels(ImageData dest,
                             int x,
                             int y,
                             int putWidth,
                             int[] pixels,
                             int startIndex)
This method doesn't appear on ImageData, but it should. But even so, they have bugs for depths greater than 8. Copy width pixel values starting at offset x in scanline y from the array pixels starting at startIndex.
Parameters:
x - the x position of the pixel to set
y - the y position of the pixel to set
putWidth - the width of the pixels to set
pixels - the pixels to set
startIndex - the index at which to begin setting
Throws:
SWTError(ERROR_NULL_ARGUMENT) - if pixels is null
SWTError(ERROR_UNSUPPORTED_DEPTH) - if the depth is not one of 1, 4, 8, 16, 24 or 32

Draw2D v2.0