| 1 |
NAME SoSFImage SoSImage "" { |
| 2 |
Field containing a 2D image |
| 3 |
} |
| 4 |
|
| 5 |
INCLUDE fields/SoSFImage.h |
| 6 |
|
| 7 |
DESC { |
| 8 |
A field containing a two-dimensional image. Images can be greyscale |
| 9 |
(intensity), greyscale with transparency information, RGB, or RGB with |
| 10 |
transparency. Each component of the image (intensity, red, green, |
| 11 |
blue or transparency (alpha)) can have an unsigned one-byte value from |
| 12 |
0 to 255. |
| 13 |
\p |
| 14 |
Values are returned as arrays of unsigned chars. The image is stored |
| 15 |
in this array starting at the bottom left corner of the image with the |
| 16 |
intensity or red component of that pixel, followed by either the alpha, |
| 17 |
the green and blue, or the green, blue and alpha components (depending |
| 18 |
on the number of components in the image). The next value is the |
| 19 |
first component of the next pixel to the right. |
| 20 |
\p |
| 21 |
\cSoSFImages\. are written to file as three integers representing the |
| 22 |
width, height and number of components in the image, followed by |
| 23 |
width*height hexadecimal values representing the pixels in the |
| 24 |
image, separated by whitespace. A one-component image will have |
| 25 |
one-byte hexadecimal values representing the intensity of the image. |
| 26 |
For example, 0xFF is full intensity, 0x00 is no intensity. A two-component |
| 27 |
image puts the intensity in the first (high) byte and the transparency |
| 28 |
in the second (low) byte. Pixels in a three-component image have the red |
| 29 |
component in the first (high) byte, followed by the green and blue |
| 30 |
components (so 0xFF0000 is red). Four-component images put the |
| 31 |
transparency byte after red/green/blue (so 0x0000FF80 is |
| 32 |
semi-transparent blue). Note: each pixel is actually read as a single |
| 33 |
unsigned number, so a 3-component pixel with value "0x0000FF" can also |
| 34 |
be written as "0xFF" or "255" (decimal). |
| 35 |
\p |
| 36 |
For example, |
| 37 |
\b |
| 38 |
1 2 1 0xFF 0x00 |
| 39 |
\. |
| 40 |
is a 1 pixel wide by 2 pixel high greyscale image, with the bottom pixel |
| 41 |
white and the top pixel black. And: |
| 42 |
\b |
| 43 |
2 4 3 0xFF0000 0xFF00 0 0 0 0 0xFFFFFF 0xFFFF00 |
| 44 |
\. |
| 45 |
is a 2 pixel wide by 4 pixel high RGB image, with the bottom left pixel red, |
| 46 |
the bottom right pixel green, the two middle rows of pixels black, the top |
| 47 |
left pixel white, and the top right pixel yellow. |
| 48 |
|
| 49 |
} |
| 50 |
|
| 51 |
METHOD "" const unsigned char *getValue(SbVec2s &size, int &nc) const { |
| 52 |
Returns the pixels in the image as an array of unsigned chars. The |
| 53 |
\asize\. and \anc\. arguments are filled in with the dimensions of the |
| 54 |
image and the number of components in the image; the number of bytes |
| 55 |
in the array returned will be \asize\.[0]*\asize\.[1]*\anc\.. |
| 56 |
} |
| 57 |
METHOD "" |
| 58 |
void setValue(const SbVec2s &size, int nc, const unsigned char *bytes) { |
| 59 |
Sets the value of this field to be an image of the given size, with |
| 60 |
the given number of components, and with the given pixel values. |
| 61 |
\asize\.[0]*\asize\.[1]*\anc\. bytes from the given array will be copied into |
| 62 |
internal storage maintained by the \cSoSFImage\. field. |
| 63 |
} |
| 64 |
METHOD "" unsigned char *startEditing(SbVec2s &size, int &nc) {} |
| 65 |
METHOD "" void finishEditing() { |
| 66 |
These methods can be used to efficiently edit the values in an image |
| 67 |
field. \mstartEditing()\. returns the size of the image in the \asize\. |
| 68 |
and \anc\. arguments; writing past the end of the array returned is a |
| 69 |
good way to cause hard-to-find core dumps. |
| 70 |
} |
| 71 |
ALSO { SoField, SoSField } |