Class encapsulating a raster image and its attributes. More...
#include <Inventor/image/SbRasterImage.h>
Public Types | |
enum | Components { UNKNOWN = -1 , LUMINANCE = 1 , LUMINANCE_TRANSPARENCY = 2 , RGB = 3 , RGB_TRANSPARENCY = 4 , RGBE = 5 } |
Components type. More... | |
enum | CopyPolicy { COPY = 0 , NO_COPY = 1 , NO_COPY_AND_DELETE = 2 , NO_COPY_AND_FREE = 3 } |
Copy policy. More... | |
Public Member Functions | |
SbRasterImage () | |
Constructor that creates an empty image. | |
SbRasterImage (const SbVec2i32 &size, Components components, SoBufferObject *bufferObject) | |
Constructor that initializes with an image. | |
virtual | ~SbRasterImage () |
Destructor. | |
void | setSize (const SbVec2s &size) |
Sets the raster image size in pixels. | |
void | setSize_i32 (const SbVec2i32 &size) |
Sets the raster image size in pixels. | |
SbVec2s | getSize () const |
Returns the raster image size in pixels. | |
SbVec2i32 | getSize_i32 () const |
Returns the raster image size in pixels for large images. | |
void | setComponents (SbRasterImage::Components comp) |
Sets the number of components in each pixel of the raster image. | |
SbRasterImage::Components | getComponents () const |
Returns the number of components of each pixel as an enum. | |
int | getComponentsSize () const |
Returns the size in bytes of each pixel in the image. | |
int | getComponentsCount () const |
Returns the number of components of each pixel. | |
void | setBuffer (SoBufferObject *bufferObject) |
Sets the pixel buffer of the raster image. | |
SoBufferObject * | getBufferObject () const |
Returns the pixel buffer of the raster image. | |
int | getNumMipmaps () |
Returns the number of mipmaps contained by the buffer. | |
CopyPolicy | getCopyPolicy () const |
Returns the current buffer copy policy. | |
SbBool | removeAlphaChannel () |
Removes the Alpha channel from the current raster image. | |
Deprecated | |
SoDEPRECATED | SbRasterImage (const SbVec2s &size, Components components, const unsigned char *bytes, CopyPolicy copy=COPY) |
Constructor that initializes with an image. | |
SoDEPRECATED | SbRasterImage (const SbVec2i32 &size, Components components, const unsigned char *bytes, CopyPolicy copy=COPY) |
Constructor that initializes with a large image. | |
SoDEPRECATED void | setBuffer (unsigned char *buffer, CopyPolicy copy=COPY) |
Sets the pixel buffer of the raster image. | |
SoDEPRECATED unsigned char * | getBuffer () const |
Returns the pixel buffer of the raster image. | |
Class encapsulating a raster image and its attributes.
This class encapsulates a raster image, including its size and number of color components.
Definition at line 56 of file SbRasterImage.h.
Components type.
Definition at line 64 of file SbRasterImage.h.
Copy policy.
Enumerator | |
---|---|
COPY | Open Inventor will make a copy of the data (default). |
NO_COPY | Passed buffer used , user will delete . |
NO_COPY_AND_DELETE | Passed buffer used, SbRasterImage will delete. Use this if memory is allocated with "new". |
NO_COPY_AND_FREE | Passed buffer used, SbRasterImage will free. Use this if memory is allocated with "malloc". |
Definition at line 101 of file SbRasterImage.h.
SbRasterImage::SbRasterImage | ( | ) |
Constructor that creates an empty image.
SbRasterImage::SbRasterImage | ( | const SbVec2i32 & | size, |
Components | components, | ||
SoBufferObject * | bufferObject | ||
) |
Constructor that initializes with an image.
Image data is assumed to be packed (no padding between pixels or rows) and pixel components are assumed to be in RGBA order.
Given some image data for which we have:
Case 1: Create raster image from image data, retaining ownership of memory.
Case 2: Create raster image from image data, making a copy of the data.
|
virtual |
Destructor.
SoDEPRECATED SbRasterImage::SbRasterImage | ( | const SbVec2s & | size, |
Components | components, | ||
const unsigned char * | bytes, | ||
CopyPolicy | copy = COPY |
||
) |
Constructor that initializes with an image.
SoDEPRECATED SbRasterImage::SbRasterImage | ( | const SbVec2i32 & | size, |
Components | components, | ||
const unsigned char * | bytes, | ||
CopyPolicy | copy = COPY |
||
) |
Constructor that initializes with a large image.
SoDEPRECATED unsigned char * SbRasterImage::getBuffer | ( | ) | const |
Returns the pixel buffer of the raster image.
SoBufferObject * SbRasterImage::getBufferObject | ( | ) | const |
Returns the pixel buffer of the raster image.
To get a pointer to the raw image data:
SbRasterImage::Components SbRasterImage::getComponents | ( | ) | const |
Returns the number of components of each pixel as an enum.
For example, an RGBA image returns RGB_TRANSPARENCY.
int SbRasterImage::getComponentsCount | ( | ) | const |
Returns the number of components of each pixel.
Returns -1 in case of invalid or unknown components type.
E.g: For an RGB image it returns 3 (R, G and B).
int SbRasterImage::getComponentsSize | ( | ) | const |
Returns the size in bytes of each pixel in the image.
Returns -1 in case of invalid or unknown components type.
E.g: For an RGB image containing byte data, the pixel size is 3 bytes.
|
inline |
Returns the current buffer copy policy.
Definition at line 416 of file SbRasterImage.h.
|
inline |
Returns the number of mipmaps contained by the buffer.
Definition at line 282 of file SbRasterImage.h.
SbVec2s SbRasterImage::getSize | ( | ) | const |
Returns the raster image size in pixels.
SbVec2i32 SbRasterImage::getSize_i32 | ( | ) | const |
Returns the raster image size in pixels for large images.
SbBool SbRasterImage::removeAlphaChannel | ( | ) |
Removes the Alpha channel from the current raster image.
If the copy policy is COPY (Open Inventor owns the memory) then the buffer is reallocated with the correct size. Otherwise the content of the buffer is just modified.
void SbRasterImage::setBuffer | ( | SoBufferObject * | bufferObject | ) |
Sets the pixel buffer of the raster image.
Image data is assumed to be packed (no padding between pixels or rows) and pixel components are assumed to be in RGBA order.
Given some image data for which we have:
Case 1: Set image data, retaining ownership of memory.
Case 2: Set image data, making a copy of image data.
SoDEPRECATED void SbRasterImage::setBuffer | ( | unsigned char * | buffer, |
CopyPolicy | copy = COPY |
||
) |
Sets the pixel buffer of the raster image.
By default, the memory policy is COPY. One of the NO_COPY options is the most likely to be efficient. For interoperability with other classes, pixel buffer must be packed and must respect the RGB ordering.
void SbRasterImage::setComponents | ( | SbRasterImage::Components | comp | ) |
Sets the number of components in each pixel of the raster image.
For example, an RGB image has 3 components.
void SbRasterImage::setSize | ( | const SbVec2s & | size | ) |
Sets the raster image size in pixels.
The parameter is the size of the whole raster image. The maximum size that can be specified using this method is 32767 by 32767 (because the parameter is an SbVec2s). To specify a larger image size use the method setSize_i32.
void SbRasterImage::setSize_i32 | ( | const SbVec2i32 & | size | ) |
Sets the raster image size in pixels.
The parameter is the size of the whole raster image to be saved. Use for sizes with at least one side greater than 32767.