SbRasterImage Class Reference
[Image]

VSG extension Class encapsulating a raster image and its attributes. More...

#include <Inventor/image/SbRasterImage.h>

List of all members.

Public Types

enum  Components {
  UNKNOWN = -1,
  LUMINANCE = 1,
  LUMINANCE_TRANSPARENCY = 2,
  RGB = 3,
  RGB_TRANSPARENCY = 4,
  RGBE = 5
}
enum  CopyPolicy {
  COPY = 0,
  NO_COPY = 1,
  NO_COPY_AND_DELETE = 2,
  NO_COPY_AND_FREE = 3
}

Public Member Functions

 SbRasterImage ()
 SbRasterImage (const SbVec2i32 &size, Components components, SoBufferObject *bufferObject)
virtual ~SbRasterImage ()
void setSize (const SbVec2s &size)
void setSize_i32 (const SbVec2i32 &size)
SbVec2s getSize () const
SbVec2i32 getSize_i32 () const
void setComponents (SbRasterImage::Components comp)
SbRasterImage::Components getComponents () const
int getComponentsSize () const
int getComponentsCount () const
void setBuffer (SoBufferObject *bufferObject)
SoBufferObjectgetBufferObject () const
int getNumMipmaps ()
CopyPolicy getCopyPolicy () const
SbBool removeAlphaChannel ()

Deprecated



SoDEPRECATED SbRasterImage (const SbVec2s &size, Components components, const unsigned char *bytes, CopyPolicy copy=COPY)
SoDEPRECATED SbRasterImage (const SbVec2i32 &size, Components components, const unsigned char *bytes, CopyPolicy copy=COPY)
SoDEPRECATED void setBuffer (unsigned char *buffer, CopyPolicy copy=COPY)
SoDEPRECATED unsigned char * getBuffer () const

Detailed Description

VSG extension Class encapsulating a raster image and its attributes.

This class encapsulates a raster image, including its size and number of color components.

SEE ALSO

SoRasterImageRW


Member Enumeration Documentation

Components type.

Enumerator:
UNKNOWN 

Unknown number of components.

LUMINANCE 

Number of components 1 (luminance).

LUMINANCE_TRANSPARENCY 

Number of components 2 (luminance + transparency).

RGB 

Number of components 3 (RGB) (default).

RGB_TRANSPARENCY 

Number of components 4 (RGB + transparency).

RGBE 

Number of components 4 (RGBE).

This is used by some HDR formats.

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".


Constructor & Destructor Documentation

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:

  • imageSize : Dimensions of image
  • imageBPP : Number of bytes per pixel (1, 2, 3, ...)
  • imageComps : Type of pixel (L, LA, RGB, RGBA, ...)
  • imageData : Pointer to image data

Case 1: Create raster image from image data, retaining ownership of memory.

   size_t numBytes = imageSize[0] * imageSize[1] * imageBPP;
   SoRef<SoCpuBufferObject> buffer = new SoCpuBufferObject( (void*)imageData, numBytes );
   SbRasterImage* rasterImage = new SbRasterImage( imageSize, imageComps, buffer.ptr() );

Case 2: Create raster image from image data, making a copy of the data.

   SoRef<SoCpuBufferObject> buffer = new SoCpuBufferObject();
     size_t numBytes = imageSize[0] * imageSize[1] * imageBPP;
     buffer->setSize( numBytes ); // Allocates memory owned by buffer object
     memcpy( buffer->map( SoBufferObject::SET ), imageData, numBytes );
     buffer->unmap();
   SbRasterImage* rasterImage = new SbRasterImage( imageSize, imageComps, buffer.ptr() );
virtual SbRasterImage::~SbRasterImage (  )  [virtual]

Destructor.

SoDEPRECATED SbRasterImage::SbRasterImage ( const SbVec2s size,
Components  components,
const unsigned char *  bytes,
CopyPolicy  copy = COPY 
)

Constructor that initializes with an image.

Deprecated:

Deprecated since Open Inventor 9400
Use SbRasterImage constructor with SoBufferObject instead.
SoDEPRECATED SbRasterImage::SbRasterImage ( const SbVec2i32 size,
Components  components,
const unsigned char *  bytes,
CopyPolicy  copy = COPY 
)

Constructor that initializes with a large image.

Deprecated:

Deprecated since Open Inventor 9400
Use SbRasterImage constructor with SoBufferObject instead.

Member Function Documentation

SoDEPRECATED unsigned char* SbRasterImage::getBuffer (  )  const

Returns the pixel buffer of the raster image.

Deprecated:

Deprecated since Open Inventor 9400
Use SbRasterImage::getBufferObject() instead.
SoBufferObject* SbRasterImage::getBufferObject (  )  const

Returns the pixel buffer of the raster image.

To get a pointer to the raw image data:

 SbRasterImage* rasterImage . . . 
 SoBufferObject* imageBuffer = rasterImage->getBufferObject();
 SoRef<SoCpuBufferObject> cpuBuffer = new SoCpuBufferObject();
 imageBuffer->map( cpuBuffer.ptr(), SoBufferObject::READ_ONLY);

   unsigned char* imageData = (unsigned char*)cpuBuffer->map(SoBufferObject::READ_ONLY);
   . . .
 cpuBuffer->unmap();
 imageBuffer->unmap(cpuBuffer.ptr());
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.

SbRasterImage::CopyPolicy SbRasterImage::getCopyPolicy (  )  const [inline]

Returns the current buffer copy policy.

int SbRasterImage::getNumMipmaps (  )  [inline]

Returns the number of mipmaps contained by the buffer.

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.

Returns:
True if the format contains an alpha channel and it was possible to remove it.
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.

Deprecated:

Deprecated since Open Inventor 9400
Use SbRasterImage::setBuffer(SoBufferObject* bufferObject) instead.
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:

  • imageSize : Dimensions of image
  • imageBPP : Number of bytes per pixel (1, 2, 3, ...)
  • imageData : Pointer to image data

Case 1: Set image data, retaining ownership of memory.

 SbRasterImage* rasterImage . . .
   size_t numBytes = imageSize[0] * imageSize[1] * imageBPP;
   SoRef<SoCpuBufferObject> buffer = new SoCpuBufferObject( (void*)imageData, numBytes );
 rasterImage->setBuffer( buffer.ptr() );

Case 2: Set image data, making a copy of image data.

 SbRasterImage* rasterImage . . .
 SoRef<SoCpuBufferObject> buffer = new SoCpuBufferObject();
   size_t numBytes = imageSize[0] * imageSize[1] * imageBPP;
   buffer->setSize( numBytes );  // Allocates memory owned by buffer object
   memcpy( buffer->map( SoBufferObject::SET ), (void*)imageData, numBytes );
   buffer->unmap();
 rasterImage->setBuffer( buffer.ptr() );
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.


The documentation for this class was generated from the following file:

Open Inventor Toolkit reference manual, generated on 15 Mar 2023
Copyright © Thermo Fisher Scientific All rights reserved.
http://www.openinventor.com/