Open Inventor Reference
SoSFImage Class Reference

Field containing a 2D image. More...

#include <Inventor/fields/SoSFImage.h>

Inheritance diagram for SoSFImage:
SoSField SoField

Public Member Functions

const unsigned char * getValue (SbVec2s &size, int &nc) const
 getValue returns the size, number of components and a constant pointer to the image. More...
 
void setValue (const SbVec2s &size, int nc, const unsigned char *bytes)
 Sets the value of this field to be an image of the given size, with the given number of components, and with the given pixel values. More...
 
bool operator== (const SoSFImage &f) const
 Equality/inequality tests. More...
 
bool operator!= (const SoSFImage &f) const
 
unsigned char * startEditing (SbVec2s &size, int &nc)
 This method can be used to efficiently edit the values in an image field. More...
 
void finishEditing ()
 Finish the editing of the field values. More...
 
- Public Member Functions inherited from SoSField
virtual ~SoSField ()
 Destructor. More...
 
- Public Member Functions inherited from SoField
virtual ~SoField ()
 Destructor. More...
 
void setIgnored (bool ig)
 Sets the ignore flag for this field. More...
 
bool isIgnored () const
 Gets the ignore flag for this field. More...
 
bool isDefault () const
 Gets the state of default flag of the field. More...
 
virtual SoType getTypeId () const =0
 Return the type identifier for this field instance (SoField *). More...
 
bool isOfType (SoType type) const
 Returns TRUE if this field is the given type or derived from that type. More...
 
void enableConnection (bool flag)
 Field connections may be enabled and disabled. More...
 
bool isConnectionEnabled () const
 Returns FALSE if connections to this field are disabled. More...
 
bool connectFrom (SoEngineOutput *engineOutput)
 Connects the field to the given output of an engine or to another field. More...
 
bool connectFrom (SoField *field)
 
void disconnect ()
 Disconnect the field from whatever it was connected to. More...
 
bool isConnected () const
 Returns TRUE if the field is connected to anything. More...
 
bool isConnectedFromEngine () const
 Returns TRUE if the field is connected to an engine's output. More...
 
bool isConnectedFromField () const
 Returns TRUE if the field is connected to another field. More...
 
bool getConnectedEngine (SoEngineOutput *&engineOutput) const
 Returns TRUE if this field is being written into by an engine, and returns the engine output it is connected to in engineOutput. More...
 
bool getConnectedField (SoField *&field) const
 Returns TRUE if this field is being written into by another field, and returns the field it is connected to in writingField. More...
 
int getForwardConnections (SoFieldList &list) const
 Adds pointers to all of the fields that this field is writing into (either fields in nodes, global fields or engine inputs) to the given field list, and returns the number of forward connections. More...
 
SoFieldContainergetContainer () const
 Returns the containing node or engine. More...
 
bool set (const char *valueString)
 Sets the field to the given value, which is an ASCII string in the Inventor file format. More...
 
void get (SbString &valueString)
 Returns the value of the field in the Inventor file format, even if the field has its default value. More...
 
virtual void touch ()
 Simulates a change to the field, causing attached sensors to fire, connected fields and engines to be marked as needing evaluation, and so forth. More...
 
bool operator== (const SoField &f) const
 Return TRUE (FALSE) if this field is of the same type and has the same value as f. More...
 
bool operator!= (const SoField &f) const
 Return TRUE (FALSE) if this field is of the same type and has the same value as f. More...
 
void setDefault (bool def)
 Sets default flag. More...
 
virtual void startNotify ()
 Initiates or propagates notification through container. More...
 
virtual void notify (SoNotList *list)
 
void setContainer (SoFieldContainer *cont)
 Sets the containing node. More...
 
bool shouldWrite () const
 Returns TRUE if the field really needs to be written out. More...
 
void addAuditor (void *auditor, SoNotRec::Type type)
 Adds/removes an auditor to/from list. More...
 
void removeAuditor (void *auditor, SoNotRec::Type type)
 
bool enableNotify (bool flag)
 Indicates whether notification will propagate as the result of setting the field value. More...
 
bool isNotifyEnabled () const
 
bool enableContainerNotify (bool flag)
 Indicates whether notification will propagate to the SoFieldContainer that owns the field. More...
 
bool isContainerNotifyEnabled () const
 
virtual void connectionStatusChanged (int numConnections)
 Indicates to a field that a change has been made involving a connection from it (as source) to another field. More...
 
bool isReadOnly () const
 If this returns TRUE, it means we're in the middle of doing a setValue()+valueChanged() and values from an upstream connection shouldn't write into this field. More...
 
virtual bool isSame (const SoField &f) const =0
 Returns TRUE if the given field is of the same type and has the same value(s) as this. More...
 
virtual void copyFrom (const SoField &f)=0
 Copies the value from one field to another, assuming same subclass. More...
 
virtual void fixCopy (bool copyConnections)
 After a field value has been copied using copyFrom(), this is called to allow fields to update the copy. More...
 
virtual bool referencesCopy () const
 This returns TRUE if this field contains a reference to a node or engine that is copied during a copy operation (i.e., it is "inside"). More...
 
void copyConnection (const SoField *fromField)
 Copies connection from one field to another. More...
 
virtual bool read (SoInput *in, const SbName &name)
 Reads value of field (with given name) from file as defined by SoInput. More...
 
virtual void write (SoOutput *out, const SbName &name) const
 Writes field (with given name) to file as defined by SoOutput. More...
 
virtual void countWriteRefs (SoOutput *out) const
 Counts write-references on field to prepare for writing. More...
 
void evaluate () const
 Evaluates the field from whatever it's connected to. More...
 

Static Public Member Functions

static void initClass ()
 
- Static Public Member Functions inherited from SoSField
static SoType getClassTypeId ()
 Return the type identifier for this field class. More...
 
static void initClass ()
 
static void * createInstance ()
 
- Static Public Member Functions inherited from SoField
static SoType getClassTypeId ()
 Return the type identifier for this field class. More...
 
static void initClass ()
 
static void initClasses ()
 Initialize ALL Inventor node classes. More...
 

Additional Inherited Members

- Protected Member Functions inherited from SoSField
 SoSField ()
 Constructor. More...
 
- Protected Member Functions inherited from SoField
 SoField ()
 Constuctor: More...
 
void valueChanged (bool resetDefault=TRUE)
 Called by an instance to indicate that a value has changed. More...
 
virtual void evaluateConnection () const
 Evaluates the field or engine the field is connected to, storing the result in the field. More...
 
virtual bool readConnection (SoInput *in)
 Reads connection. More...
 
virtual void writeConnection (SoOutput *out) const
 Writes field connection. More...
 

Detailed Description

A field containing a two-dimensional image. Images can be greyscale (intensity), greyscale with transparency information, RGB, or RGB with transparency. Each component of the image (intensity, red, green, blue or transparency (alpha)) can have an unsigned one-byte value from 0 to 255.

Values are returned as arrays of unsigned chars. The image is stored in this array starting at the bottom left corner of the image with the intensity or red component of that pixel, followed by either the alpha, the green and blue, or the green, blue and alpha components (depending on the number of components in the image). The next value is the first component of the next pixel to the right.

SoSFImages are written to file as three integers representing the width, height and number of components in the image, followed by width*height hexadecimal values representing the pixels in the image, separated by whitespace. A one-component image will have one-byte hexadecimal values representing the intensity of the image. For example, 0xFF is full intensity, 0x00 is no intensity. A two-component image puts the intensity in the first (high) byte and the transparency in the second (low) byte. Pixels in a three-component image have the red component in the first (high) byte, followed by the green and blue components (so 0xFF0000 is red). Four-component images put the transparency byte after red/green/blue (so 0x0000FF80 is semi-transparent blue). Note: each pixel is actually read as a single unsigned number, so a 3-component pixel with value "0x0000FF" can also be written as "0xFF" or "255" (decimal).

For example,

1 2 1 0xFF 0x00

is a 1 pixel wide by 2 pixel high greyscale image, with the bottom pixel white and the top pixel black. And:

2 4 3 0xFF0000 0xFF00 0 0 0 0 0xFFFFFF 0xFFFF00

is a 2 pixel wide by 4 pixel high RGB image, with the bottom left pixel red, the bottom right pixel green, the two middle rows of pixels black, the top left pixel white, and the top right pixel yellow.

See Also
SoField, SoSField

Definition at line 117 of file SoSFImage.h.

Member Function Documentation

◆ finishEditing()

void SoSFImage::finishEditing ( )

◆ getValue()

const unsigned char* SoSFImage::getValue ( SbVec2s size,
int &  nc 
) const

◆ initClass()

static void SoSFImage::initClass ( )
static

◆ operator!=()

bool SoSFImage::operator!= ( const SoSFImage f) const
inline

Definition at line 137 of file SoSFImage.h.

◆ operator==()

bool SoSFImage::operator== ( const SoSFImage f) const

◆ setValue()

void SoSFImage::setValue ( const SbVec2s size,
int  nc,
const unsigned char *  bytes 
)

size[0]*size[1]*nc bytes from the given array will be copied into internal storage maintained by the SoSFImage field.

◆ startEditing()

unsigned char* SoSFImage::startEditing ( SbVec2s size,
int &  nc 
)

startEditing() returns the size of the image in the size and nc arguments; writing past the end of the array returned is a good way to cause hard-to-find core dumps. Do not forget to call finishEditing() after the modification has been done.


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