|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
waba.lang.Object | +--waba.fx.Image
Image is a rectangular image.
You can draw into an image and copy an image to a surface using a Graphics object.
Graphics
Constructor Summary | |
Image(int width,
int height)
Creates an image of the specified width and height. |
|
Image(String path)
Loads and constructs an image from a file. |
Method Summary | |
void |
free()
Sets the image width and height to 0 and frees any systems resources associated with the image. |
int |
getHeight()
Returns the height of the image. |
int |
getWidth()
Returns the width of the image. |
void |
setPixels(int bitsPerPixel,
int[] colorMap,
int bytesPerRow,
int numRows,
int y,
byte[] pixels)
Sets one or more row(s) of pixels in an image. |
Methods inherited from class waba.lang.Object |
toString |
Constructor Detail |
public Image(int width, int height)
public Image(String path)
Method Detail |
public void setPixels(int bitsPerPixel, int[] colorMap, int bytesPerRow, int numRows, int y, byte[] pixels)
Each color in the color map of the source pixels is identified by a single integer value. The integer is composed of 8 bits (value [0..255]) of red, green and blue using the following calculation:
int color = (red << 16) | (green << 8) | blue;As an example, to load a 16 color image, we would pass bitsPerPixel as 4 and would create a int array of 16 values for the color map. Then we would set each of the values in the color map to the colors used using the equation above. We could then either read data line by line from the source stream, calling this method for each row of pixels or could read a number of rows at once and then call this method to set the pixels.
The former approach uses less memory, the latter approach is faster.
bitsPerPixel
- bits per pixel of the source pixels (1, 4 or 8)colorMap
- the color map of the source pixels (must be 2, 16 or 256 in length)bytesPerRow
- number of bytes per row of pixels in the source pixels arraynumRows
- the number of rows of pixels in the source pixels arrayy
- y coordinate in the image to start setting pixelspixels
- array containing the source pixelspublic void free()
public int getHeight()
public int getWidth()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |