|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
DirectGraphics contains some graphics extensions for MIDP Graphics, with which polygons and triangles can be drawn and filled, images can be rotated or flipped, alpha channel color supported and raw pixel data can be directly obtained from the graphics context or drawn to it.
DirectUtils.getDirectGraphics(Graphics g)
method can be used to
convert lcdui Graphics to Nokia DirectGraphics object:
DirectGraphics dg = DirectUtils.getDirectGraphics(g);The operations to DirectGraphics reference will also affect the original graphics context, for example, setting the color with DirectGraphics will change the current painting color for Graphics and vice versa. In fact, the developer can see DirectGraphics as a new way to do calls to Graphics. DirectGraphics does not inherit the standard Graphics because of API dependency. Following methods in Graphics affect also rendering operations of DirectGraphics:
ARGB values used with some methods of this interface are interpreted
with the least significant eight bits giving the blue component, the
next eight more significant bits, the green component, the next eight
more significant bits, the red component, and the next eight more
significant bits, the alpha component. In other words, the color
component is specified in the form of 0xAARRGGBB. This corresponds to
the native format specified by TYPE_INT_8888_ARGB
.
Manipulation parameters to drawPixels are formed by bitwise ORring FLIP_HORIZONTAL or FLIP_VERTICAL with a degree value: ROTATE_90, ROTATE_180 or ROTATE_270. Currently only these fixed rotation values are supported. The image is rotated counter-clockwise. The result from a combined manipulation is that first the rotation will be done, then the vertical flip, and finally the horizontal flip. Since the manipulation parameters are passed in a single integer the MIDlet cannot dictate the order of flips or rotation. There is always at most a single rotation, a single horizontal flip and a single vertical flip done. For instance, if a manipulation argument is: (FLIP_HORIZONTAL | FLIP_VERTICAL | ROTATE_90 ), the image is rotated 90 degrees counter-clockwise and after that it is flipped vertically and then horizontally. In methods that have anchor point parameter the manipulation is done before any anchor point is considere and the anchor point is applied after the manipulation.
High-order bits in color values specify opacity. A value of 0 means fully transparent pixel, non-zero values are treated as non-transparent (largest possible value means fully opaque and values in between either fully opaque or semi-opaque). As an example, in int based color values 0x00RRGGBB specifies a fully transparent pixel and 0xFFRRGGBB specifies a fully opaque pixel. Implementations must treat any pixel with a non-zero top byte as being non-transparent.
For on-screen graphics contexts the get operations will return transparency information as fully opaque. On rendering operations Porter-Duff Source Over Destination rule is used (T. Porter and T. Duff, "Compositing Digital Images", SIGGRAPH 84, 253-259).
Note on alpha use with MIDP Graphics operations
Alpha value set with setARGBColor(int) is used in javax.microedition.lcdui.Graphics drawing methods that use the current color of Graphics.
The alpha value is set to fully opaque when calls to following Graphics methods are made:
Field Summary | |
static int |
FLIP_HORIZONTAL
Constant for horizontal image flipping. |
static int |
FLIP_VERTICAL
Constant for vertical image flipping. |
static int |
ROTATE_180
Constant for rotating an image 180 degrees counter-clockwise. |
static int |
ROTATE_270
Constant for rotating an image 270 degrees counter-clockwise. |
static int |
ROTATE_90
Constant for rotating an image 90 degrees counter-clockwise. |
static int |
TYPE_BYTE_1_GRAY
1 bit format, 2 distinct color values (on/off), stored as a byte. 8 pixel values in a single byte, packed as closely as possible. |
static int |
TYPE_BYTE_1_GRAY_VERTICAL
1 bit format, 2 distinct color values (on/off), stored as a byte. 8 pixel values are stored in a single byte. |
static int |
TYPE_BYTE_2_GRAY
2 bit format, 4 gray scale colors. |
static int |
TYPE_BYTE_332_RGB
3 bits for red, 3 bits for green, and 2 bits for blue component in a pixel, stored as a byte. |
static int |
TYPE_BYTE_4_GRAY
4 bit format, 16 gray scale colors. |
static int |
TYPE_BYTE_8_GRAY
8 bit format, 256 gray scale colors. |
static int |
TYPE_INT_888_RGB
8 bits for red, green and blue component in a pixel (0x00RRGGBB). |
static int |
TYPE_INT_8888_ARGB
8 bits for alpha, red, green and blue component in a pixel (0xAARRGGBB). |
static int |
TYPE_USHORT_1555_ARGB
1 bit for alpha, 5 bits for red, green and blue component in a pixel. |
static int |
TYPE_USHORT_444_RGB
4 bits for red, green and blue component in a pixel, stored as a short (0x0RGB). |
static int |
TYPE_USHORT_4444_ARGB
4 bits for alpha, red, green and blue component in a pixel, stored as a short (0xARGB). |
static int |
TYPE_USHORT_555_RGB
5 bits for red, green and blue component in a pixel. |
static int |
TYPE_USHORT_565_RGB
5 bits for red, 6 bits for green and 5 bits for blue component in a pixel. |
Method Summary | |
void |
drawImage(javax.microedition.lcdui.Image img,
int x,
int y,
int anchor,
int manipulation)
Deprecated. As of Nokia UI API 1.1 in devices with MIDP 2.0 or higher, replaced by javax.microedition.lcdui.Graphics.drawRegion(javax.microedition.lcdui.Image, int, int, int, int, int, int, int, int). |
void |
drawPixels(byte[] pixels,
byte[] transparencyMask,
int offset,
int scanlength,
int x,
int y,
int width,
int height,
int manipulation,
int format)
Copies or draws the pixel data directly to the graphics context to a specific location. |
void |
drawPixels(int[] pixels,
boolean transparency,
int offset,
int scanlength,
int x,
int y,
int width,
int height,
int manipulation,
int format)
Copies or draws the pixel data directly to the graphics context to a specific location from the array starting from the specified offset. |
void |
drawPixels(short[] pixels,
boolean transparency,
int offset,
int scanlength,
int x,
int y,
int width,
int height,
int manipulation,
int format)
Copies or draws the pixel data directly to the graphics context to specific a location. |
void |
drawPolygon(int[] xPoints,
int xOffset,
int[] yPoints,
int yOffset,
int nPoints,
int argbColor)
Draws a closed polygon defined by the arrays of the x- and y-coordinates. |
void |
drawTriangle(int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int argbColor)
Draws a closed triangle defined by coordinates. |
void |
fillPolygon(int[] xPoints,
int xOffset,
int[] yPoints,
int yOffset,
int nPoints,
int argbColor)
Fills a closed polygon defined by the arrays of the x- and y-coordinates. |
void |
fillTriangle(int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int argbColor)
Fills a closed triangle defined by coordinates. |
int |
getAlphaComponent()
Gets the alpha component of the current color. |
int |
getNativePixelFormat()
Returns the native pixel format of an implementation. |
void |
getPixels(byte[] pixels,
byte[] transparencyMask,
int offset,
int scanlength,
int x,
int y,
int width,
int height,
int format)
Copies the pixel (including any transparency mask) values of the graphics context from a specific location to an array of byte values. |
void |
getPixels(int[] pixels,
int offset,
int scanlength,
int x,
int y,
int width,
int height,
int format)
Copies the pixel values of the graphics context from a specific location to an array of int values. |
void |
getPixels(short[] pixels,
int offset,
int scanlength,
int x,
int y,
int width,
int height,
int format)
Copies the pixel values of the graphics context from a specific location to an array of short values. |
void |
setARGBColor(int argbColor)
Sets the current color (and alpha) to the specified ARGB value (0xAARRGGBB). |
Field Detail |
public static final int FLIP_HORIZONTAL
Value 0x2000 is assigned to FLIP_HORIZONTAL.
drawImage(Image img, int x, int y, int anchor, int manipulation)
,
Constant Field Valuespublic static final int FLIP_VERTICAL
Value 0x4000 is assigned to FLIP_VERTICAL.
drawImage(Image img, int x, int y, int anchor, int manipulation)
,
Constant Field Valuespublic static final int ROTATE_90
(ROTATE_90 * 2) results in a 180 degree rotate.
(ROTATE_90 * 3) results in a 270 degree rotate.
Value 90 is assigned to ROTATE_90.
drawImage(Image img, int x, int y, int anchor, int manipulation)
,
Constant Field Valuespublic static final int ROTATE_180
Value 180 is assigned to ROTATE_180.
drawImage(Image img, int x, int y, int anchor, int manipulation)
,
Constant Field Valuespublic static final int ROTATE_270
Value 270 is assigned to ROTATE_270.
drawImage(Image img, int x, int y, int anchor, int manipulation)
,
Constant Field Valuespublic static final int TYPE_BYTE_1_GRAY
Consider the following 9x9 graphics context where '+' indicates that the pixels are set to the "on" position: "MSB" = The most significant bit in a byte in the array that the data is copied to "LSB" = The least significant bit in a byte "|" = Byte bounds "Bit#" = the bits in the first row of the pixels array that the data is copied to MSB LSB Bit#-> 0 1 2 3 4 5 6 7 0 ------------------------ + + +|+ + + + |+ + + + + + | + + + + + + +| + + + + +|+ + + + + + | + + + + + + +| + + + + +|+ + + +| + + +|+ byte[] byteArray = new byte[11]; getPixels(byteArray, null, 0, 9, 0, 0, 9, 9, TYPE_BYTE_1_GRAY); After this the byteArray contains the following values: byteArray[0] = (byte) 0xC1; // binary 11000001 byteArray[1] = (byte) 0xF0; // binary 11110000 byteArray[2] = (byte) 0xFC; // binary 11111100 byteArray[3] = (byte) 0x7F; // binary 01111111 byteArray[4] = (byte) 0x3D; // binary 00111101 byteArray[5] = (byte) 0xDE; // binary 11011110 byteArray[6] = (byte) 0x7F; // binary 01111111 byteArray[7] = (byte) 0x1F; // binary 00011111 byteArray[8] = (byte) 0x87; // binary 10000111 byteArray[9] = (byte) 0xC1; // binary 11000001 byteArray[10] = (byte) 0x80; // binary 10000000Note that only one bit was defined for the byte stored in index 10 of byteArray; all other bits in this byte were left unchanged.
Value 1 is assigned to TYPE_BYTE_1_GRAY.
public static final int TYPE_BYTE_1_GRAY_VERTICAL
The scanlength and offset parameters for drawPixels and getPixels are given in the number of pixels, not as indices to the pixels array. In TYPE_BYTE_1_GRAY_VERTICAL format, the scanlength is not an offset that is based on indices of a pixels array, it is an offset between consecutive rows in the image representation of the pixels array. In normal the normal use of TYPE_BYTE_1_GRAY_VERTICAL, as in other formats, the scanlength is the width of the image stored in the pixels array.
If the height of a given graphic context is not divisible by 8, there are overflow bits in bytes, which are used to store the last pixels of the last rows. These are left unchanged in getPixels and drawPixels methods.
For example, the getPixels method works in TYPE_BYTE_1_GRAY_VERTICAL format in the following fashion: the bit_location starting from 0 indicates the most significant bit of the first byte of the array. A bit_location 7 thus indicates the least significant bit of the first byte of the array, and a bit_location 8 indicates the most significant bit of the second byte of the array.
P((x1+x), (y1+y)) is stored in bit_location: (((((offset/scanlength)+y1)/8)*scanlength) + ((offset%scanlength)+x1))*8 + 7 - (((offset/scanlength)+ y1)%8) for each P((x1+x), (y1+y)), where (0 <= x1 < width) and (0 <= y1 < height).
Example 1: Consider the following 9x9 graphics context where '+' indicates that the pixels set to the "on" position: Byte# 0 1 2 3 4 5 6 7 8 Bit# ------------------------------ LSB + + + + 7 + + + + + 6 + + + + + + 5 + + + + + + + 4 + + + + + + + 3 + + + + + + + 2 + + + + + + 1 MSB + + + + + 0 + + + + 7 byte[] byteArray = new byte[18]; getPixels(byteArray, null, 0, 9, 0, 0, 9, 9, TYPE_BYTE_1_GRAY_VERTICAL); After this, the byteArray contains following values: byteArray[0] = (byte) 0xFF; // binary 11111111 byteArray[1] = (byte) 0xFF; // binary 11111111 byteArray[2] = (byte) 0x0E; // binary 00001110 byteArray[3] = (byte) 0x1C; // binary 00011100 byteArray[4] = (byte) 0x38; // binary 00111000 byteArray[5] = (byte) 0x70; // binary 01110000 byteArray[6] = (byte) 0xE0; // binary 11100000 byteArray[7] = (byte) 0xFF; // binary 11111111 byteArray[8] = (byte) 0xFF; // binary 11111111 byteArray[9] = (byte) 0x01; // binary 00000001 byteArray[10] = (byte) 0x01; // binary 00000001 byteArray[11] = (byte) 0x00; // binary 00000000 byteArray[12] = (byte) 0x00; // binary 00000000 byteArray[13] = (byte) 0x00; // binary 00000000 byteArray[14] = (byte) 0x00; // binary 00000000 byteArray[15] = (byte) 0x00; // binary 00000000 byteArray[16] = (byte) 0x01; // binary 00000001 byteArray[17] = (byte) 0x01; // binary 00000001Note that only one bit (LSB) was defined for the bytes stored in indices 9-17 of byteArray; all other bits in those bytes were left unchanged.
Example 2: Consider the following 10x13 graphics context where '+' indicates the pixels set to the "on" position: x: 0 1 2 3 4 5 6 7 8 9 y: 0 1 2 3 + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 7 + + + + + 8 + + + + + 9 + + + + + 10 + + + + + 11 + + + + + 12 byte [] ba = new byte [30]; // 2 * scanlength * 8 pixels int offset = 16; int scanlength = 15; int x = 4; int y = 4; int width = 5; int height = 9; int format = TYPE_BYTE_GRAY_1_VERTICAL; DirectGraphics dg = DirectUtils.getDirectGraphics(g); dg.getPixels (ba, null, offset, scanlength, x, y, width, height, format); Now the ba array contains the following values: ba[0] = (byte) 0x00; ba[1] = (byte) 0xFE; //bits 11111110 same value for ba[1] to ba[5] ba[6] = (byte) 0x00; same value for ba[6] to ba[15] ba[16] = (byte) 0x03; //bits 00000011 same value for ba[16] to ba[20] ba[21] = (byte) 0x00; same value for ba[21] to ba[29] Same as the following figure: 1 1 1 1 1 1 x: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 y: 0 + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 7 + + + + + 8 + + + + + 9 10 11 12 13 14 15
Value -1 is assigned to TYPE_BYTE_1_GRAY_VERTICAL.
public static final int TYPE_BYTE_2_GRAY
Value 2 is assigned to TYPE_BYTE_2_GRAY.
public static final int TYPE_BYTE_4_GRAY
Value 4 is assigned to TYPE_BYTE_4_GRAY.
public static final int TYPE_BYTE_8_GRAY
Value 8 is assigned to TYPE_BYTE_8_GRAY.
public static final int TYPE_BYTE_332_RGB
Value 332 is assigned to TYPE_BYTE_332_RGB.
public static final int TYPE_USHORT_4444_ARGB
Value 4444 is assigned to TYPE_USHORT_4444_ARGB.
public static final int TYPE_USHORT_444_RGB
Value 444 is assigned to TYPE_USHORT_444_RGB.
public static final int TYPE_USHORT_555_RGB
Value 555 is assigned to TYPE_USHORT_555_RGB.
public static final int TYPE_USHORT_1555_ARGB
Value 1555 is assigned to TYPE_USHORT_1555_ARGB.
public static final int TYPE_USHORT_565_RGB
Value 565 is assigned to TYPE_USHORT_565_RGB.
public static final int TYPE_INT_888_RGB
Value 888 is assigned to TYPE_INT_888_RGB.
public static final int TYPE_INT_8888_ARGB
Value 8888 is assigned to TYPE_INT_8888_ARGB.
Method Detail |
public void setARGBColor(int argbColor)
Note that since all rendering operations defined in DirectGraphics define the color value as a parameter in the call, using this method affects only rendering operations of Graphics class. It should also be noted that the use of this method is reasonable only if alpha blending is supported by the device in Graphics operations.
For setting a fully opaque drawing color applications should use methods of Graphics class, like Graphics setColor(int RGB).
See also note about relation to Graphics set color methods. High-order byte specifies opacity; that is, 0x00xxxxxx specifies a fully transparent pixel and 0xffxxxxxx specifies a fully opaque pixel. Implementations must treat any pixel with a nonzero top byte as being non- transparent. I.e. If alpha-blending is not supported then non-zero top byte means a fully opaque color. Most implementations treat non- zero top byte as fully opaque, i.e. alpha blending is not implemented.
Note: Following two calls both results a fully transparent red color, i.e. nothing is drawn:
setARGBColor(0xFF0000); setARGBColor(0x00FF0000);
argbColor
- the color being setpublic void drawImage(javax.microedition.lcdui.Image img, int x, int y, int anchor, int manipulation)
Graphics
.
The image can be drawn in different positions relative to the
anchor point by
passing the appropriate position constants.
img
- the image specified to be drawnx
- the x-coordinate of the anchor pointy
- the y-coordinate of the anchor pointanchor
- the anchor point for positioning the imagemanipulation
- flip or rotate value or a combination of values, 0
if none
java.lang.IllegalArgumentException
- if anchor is not a legal
value or manipulation is not supported
java.lang.NullPointerException
- if img is nullImage
,
FLIP_VERTICAL
,
FLIP_HORIZONTAL
,
ROTATE_90
,
ROTATE_180
,
ROTATE_270
,
"Anchor definitions in Graphics"public void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, int argbColor)
Note that the method uses the color passed as a parameter for drawing the triangle and not the current active color of graphics context. The call does not change the current active drawing color of the graphics context.
x1
- the x-coordinate of the first vertexy1
- the y-coordinate of the first vertexx2
- the x-coordinate of the second vertexy2
- the y-coordinate of the second vertexx3
- the x-coordinate of the third vertexy3
- the y-coordinate of the third vertexargbColor
- the ARGB color value used in painting the trianglepublic void fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3, int argbColor)
Note that the method uses the color passed as a parameter for drawing the triangle and not the current active color of the graphics context. The call does not change the current active drawing color of the graphics context.
x1
- the x-coordinate of the first vertexy1
- the y-coordinate of the first vertexx2
- the x-coordinate of the second vertexy2
- the y-coordinate of the second vertexx3
- the x-coordinate of the third vertexy3
- the y-coordinate of the third vertexargbColor
- the ARGB color value used in painting the trianglepublic void drawPolygon(int[] xPoints, int xOffset, int[] yPoints, int yOffset, int nPoints, int argbColor)
This method draws the polygon defined by nPoint line segments, where the first nPoint - 1 line segments are line segments from (xPoints[xOffset + i - 1], yPoints[yOffset + i - 1]) to (xPoints[xOffset + i], yPoints[yOffset + i]), for 1 <= i <= nPoints. The figure is automatically closed by drawing a line connecting the final point to the first point if those points are different.
xPoints
- an array of x-coordinatesxOffset
- an offset to first x point in xPointsyPoints
- an array of y-coordinatesyOffset
- an offset to first y point in yPointsnPoints
- the total number of pointsargbColor
- the ARGB color value used in painting the polygon
java.lang.NullPointerException
- if xPoints or yPoints array is null.
java.lang.ArrayIndexOutOfBoundsException
- if requested to access xPoints
or
yPoints beyond the length of the arrays or with a negative indexpublic void fillPolygon(int[] xPoints, int xOffset, int[] yPoints, int yOffset, int nPoints, int argbColor)
This method draws the polygon defined by nPoint line segments, where the first nPoint - 1 line segments are line segments from (xPoints[xOffset + i - 1], yPoints[yOffset + i - 1]) to (xPoints[xOffset + i], yPoints[yOffset + i]), for 1 <= i <= nPoints. The figure is automatically closed by drawing a line connecting the final point to the first point if those points are different.
The area inside the polygon is defined using an even-odd fill rule, which is also known as the alternating rule.
xPoints
- an array of x-coordinatesxOffset
- an offset to first x point in xPointsyPoints
- an array of y-coordinatesyOffset
- an offset to first y point in yPointsnPoints
- the total number of pointsargbColor
- the ARGB color value used in painting the polygon
java.lang.NullPointerException
- if xPoints or yPoints array is null.
java.lang.ArrayIndexOutOfBoundsException
- if requested to access xPoints
or yPoints beyond the length of the arrays or with a negative
indexpublic void drawPixels(int[] pixels, boolean transparency, int offset, int scanlength, int x, int y, int width, int height, int manipulation, int format)
This method accepts only int-based formats. Passing all other formats will result in an IllegalArgumentException. Note that it is possible that no int-based pixel format is supported by an implementation.
The operation is subject to the current clip region and translation for this Graphics object.
The boolean value transparency will indicate whether the pixel's transparency value will be checked. If the transparency argument is false, the pixels are set to the graphics context without comparing the transparency values. If the transparency argument is true, the pixel's transparency value is checked and it will affect the drawing of a pixel.
The drawPixels paints the pixel data in the graphics context in the following fashion:
P(x1, y1) = pixels[offset + (x1 - x) + (y1 - y) * scanlength], for each P(x1, y1), where (x <= x1 < x + width) and (y <= y1 < y + height).
pixels
- an array of pixel values (0xAARRGGBB)transparency
- true if the pixel's transparency value will be
checkedoffset
- the index of the first pixel valuescanlength
- the relative array offset between the corresponding
pixels in consecutive rowsx
- the horizontal rendering location in the graphics contexty
- the vertical rendering location in the graphics contextwidth
- the width of the region to be renderedheight
- the height of the region to be renderedmanipulation
- the manipulation done to the image before the
draw, 0 means none.format
- the format which the pixels are provided in
java.lang.NullPointerException
- if pixels is null
java.lang.ArrayIndexOutOfBoundsException
- if requested to
access
pixels beyond the length of array or with negative index
java.lang.IllegalArgumentException
- if manipulation is unknown,
width or height is negative, or the format is wrong or unsupportedpublic void drawPixels(byte[] pixels, byte[] transparencyMask, int offset, int scanlength, int x, int y, int width, int height, int manipulation, int format)
This method accepts only byte-based formats. Passing all other formats will result in an IllegalArgumentException.
The operation is subject to the current clip region and translation for this Graphics object. Bytes in pixels and transparencyMask arrays will be passed in the same format. The transparencyMask can be null. If the transparency mask is null, the image is considered fully opaque. For pixel formats TYPE_BYTE_1_GRAY and TYPE_BYTE_1_GRAY_VERTICAL bit value 0 means fully transparent pixel, 1 means fully opaque pixel. For other byte formats the transparency information is as wide as color information for one pixel, for example, in TYPE_BYTE_2_GRAY 2 bits are used for stroring transparency information in transparencyMask. The semantics for mask values are same as in alpha channel use. Zero value indicates fully transparent pixel, non-zero values are treated as non-transparent (largest possible value means fully opaque and values in between either fully opaque or semi-opaque).
Note that scanlength and offset parameters indicate the scanlength and offset in number of pixels. This is not necessarily the same as array indices since multiple pixels may be stored in a byte.
pixels
- an array of pixel valuestransparencyMask
- an array defining the transparency maskoffset
- the index of the first pixel and the mask valuescanlength
- the relative array offset between the corresponding
pixels and the mask value in consecutive rowsx
- the horizontal rendering location in the graphics contexty
- the vertical rendering location in the graphics contextwidth
- the width of the region to be renderedheight
- the height of the region to be renderedmanipulation
- the manipulation done to the image before the
draw, 0 means none.format
- the format which the pixels are provided in
java.lang.NullPointerException
- if pixels is null
java.lang.ArrayIndexOutOfBoundsException
- if requested to
access
beyond the length of array or with negative index
java.lang.IllegalArgumentException
- if manipulation is unknown,
width or height is negative, or the format is wrong or unsupportedpublic void drawPixels(short[] pixels, boolean transparency, int offset, int scanlength, int x, int y, int width, int height, int manipulation, int format)
This method accepts only short-based formats. Passing all other formats will result in an IllegalArgumentException. Note that it is possible that no short-based pixel format is supported by an implementation.
The operation is subject to the current clip region and translation for this Graphics object. The boolean value transparency will indicate whether the pixel's transparency value will be checked. If the transparency argument is false, the pixels are set to the graphics context without comparing the transparency values. If the transparency argument is true, the pixel's transparency value is checked and it will affect the drawing of a pixel.
The drawPixels paints the pixel data in the graphics context in the following fashion:
P(x1, y1) = pixels[offset + (x1 - x) + (y1 - y) * scanlength], for each P(x1, y1), where (x <= x1 < x + width) and (y <= y1 < y + height).
pixels
- an array of pixel valuestransparency
- true if the pixel's transparency value will be
checkedoffset
- the index of the first pixel valuescanlength
- the relative array offset between the corresponding
pixels in consecutive rowsx
- the horizontal rendering location in the graphics contexty
- the vertical rendering location in the graphics contextwidth
- the width of the region to be renderedheight
- the height of the region to be renderedmanipulation
- the manipulation done to the image before the
draw, 0 means none.format
- the format which the pixels are provided in
java.lang.NullPointerException
- if pixels is null
java.lang.ArrayIndexOutOfBoundsException
- if requested to
access beyond the length of array or with negative index
java.lang.IllegalArgumentException
- if manipulation is unknown,
width or height is negative, or the format is wrong or unsupportedpublic void getPixels(int[] pixels, int offset, int scanlength, int x, int y, int width, int height, int format)
This method returns only int-based formats. Requesting all other formats will result in an IllegalArgumentException.
Throws ArrayIndexOutOfBoundsException if array size is too small for image pixels.
The current clip region does not affect pixel values stored in the pixels array, i.e. even if a clip region is set and the region intersects the region queried with this method, also the clip region pixels are stored in the pixels array. The operation is subject to the current translation for this Graphics object.
The getPixels methods stores the pixel data to the pixels array in the following fashion:
pixels[offset + (x1 - x) + (y1 - y) * scanlength] = P(x1, y1), for each P(x1, y1), where (x <= x1 < x + width) and (y <= y1 < y + height).
pixels
- an array which the pixel information will be stored inoffset
- the index to the pixels array where the first pixel
value will be storedscanlength
- the relative offset in the pixels array between
corresponding pixels in consecutive rowsx
- the x-coordinate of the upper left corner of the region in
the graphics contexty
- the y-coordinate of the upper left corner of the region in
the graphics contextwidth
- the width of the region in graphics contextheight
- the height of the region in graphics contextformat
- the format which the pixels are requested in
java.lang.NullPointerException
- if pixels is null
java.lang.ArrayIndexOutOfBoundsException
- if array size is too
small for the image pixels or negative index access is
attempted, contents of the array remain unchanged
java.lang.IllegalArgumentException
- if x, y, width or height is
negative, or the format is wrong or unsupportedpublic void getPixels(byte[] pixels, byte[] transparencyMask, int offset, int scanlength, int x, int y, int width, int height, int format)
This method returns only byte-based formats. Requesting all other formats will result in an IllegalArgumentException.
Throws
ArrayIndexOutOfBoundsException if array size is too small for image
pixels or transparency mask.
The argument transparencyMask can be null if the caller is not
interested in getting the mask. See
transparencyMask
definition on drawPixels(...).
Note that the scanlength and offset parameters indicate the scanlength and offset in number of pixels. This is not necessarily the same as array indices since multiple pixels may be stored in a byte.
The current clip region does not affect pixel values stored in the pixels array, i.e. even if a clip region is set and the region intersects the region queried with this method, also the clip region pixels are stored in the pixels array. The operation is subject to the current translation for this Graphics object.
pixels
- an array which the pixel information will be stored intransparencyMask
- an array which the transparency mask will be
stored inoffset
- offset in the array where the first pixel and mask value
will be storedscanlength
- the relative offset in the array between the
corresponding pixels and the mask value in consecutive rowsx
- the x-coordinate of the upper left corner of the region in
the graphics contexty
- the y-coordinate of the upper left corner of the region in
the graphics contextwidth
- the width of the region in the graphics contextheight
- the height of the region in the graphics contextformat
- the format which the pixels are requested in
java.lang.NullPointerException
- if pixels is null
java.lang.ArrayIndexOutOfBoundsException
- if array size is too
small
for the image pixels or negative index access is attempted, contents
of the array remain unchanged
java.lang.IllegalArgumentException
- if x, y, width or height is
negative, or the format is wrong or unsupportedpublic void getPixels(short[] pixels, int offset, int scanlength, int x, int y, int width, int height, int format)
This method returns only short-based formats. Requesting all other formats will result in an IllegalArgumentException.
Throws ArrayIndexOutOfBoundsException if array size is too small for image pixels.
The current clip region does not affect pixel values stored in the pixels array, i.e. even if a clip region is set and the region intersects the region queried with this method, also the clip region pixels are stored in the pixels array. The operation is subject to the current translation for this Graphics object.
The getPixels methods stores the pixel data to the pixels array in the following fashion:
pixels[offset + (x1 - x) + (y1 - y) * scanlength] = P(x1, y1), for each P(x1, y1), where (x <= x1 < x + width) and (y <= y1 < y + height).
pixels
- an array which the pixel information will be stored inoffset
- the index in the array where the first pixel value will
be storedscanlength
- the relative offset in the array between the
corresponding pixels in consecutive rowsx
- the x-coordinate of the upper left corner of the region in
the graphics contexty
- the y-coordinate of the upper left corner of the region in
the graphics contextwidth
- the width of the region in the graphics contextheight
- the height of the region in the graphics contextformat
- the format which the pixels are requested in
java.lang.NullPointerException
- if pixels is null
java.lang.ArrayIndexOutOfBoundsException
- if array size is too
small for the image pixels or negative index access is
attempted, contents of the array remain unchanged
java.lang.IllegalArgumentException
- if x, y, width or height is
negative, or the format is wrong or unsupportedpublic int getNativePixelFormat()
TYPE_BYTE_1_GRAY
or
TYPE_USHORT_4444_ARGB
.
The native format is the most efficient format supported by the
drawPixels
and getPixels methods of specific implementation. An implementation
must support
the format that it returns from this method. Implementation may
support
also other pixel formats.
public int getAlphaComponent()
|
forum.nokia.com/java | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |