SoSFImage(3)
π SoSFImage(3) β Library Functions Manual π
β¨ NAME β¨
SoSFImage β bestie, this class is literally used to store pixel images. That's the whole point. π
πΈ SYNOPSIS πΈ
#include <Inventor/fields/SoSFImage.h>
Inherits SoSField.
π Public Types π
enum CopyPolicy { COPY, NO_COPY, NO_COPY_AND_DELETE, NO_COPY_AND_FREE }
π¦ Public Types inherited from SoField π¦
enum FieldType { NORMAL_FIELD = 0, EVENTIN_FIELD, EVENTOUT_FIELD, EXPOSED_FIELD }
β¨ Public Member Functions β¨
okay so here's the entire roster, and I mean entire β no skipping, no cap:
virtual SoType getTypeId (void) constvirtual void copyFrom (const SoField &field)const SoSFImage & operator= (const SoSFImage &field)virtual SbBool isSame (const SoField &field) constconst unsigned char * getValue (SbVec2s &size, int &nc) constconst SbImage & getValue () constvoid setValue (const SbVec2s &size, const int nc, const unsigned char *pixels, CopyPolicy copypolicy=COPY)int operator== (const SoSFImage &field) constint operator!= (const SoSFImage &field) constunsigned char * startEditing (SbVec2s &size, int &nc)void finishEditing (void)void setSubValue (const SbVec2s &dims, const SbVec2s &offset, unsigned char *pixels)void setSubValues (const SbVec2s *dims, const SbVec2s *offsets, int num, unsigned char **pixelblocks)unsigned char * getSubTexture (int idx, SbVec2s &dims, SbVec2s &offset) constSbBool hasSubTextures (int &numsubtextures)void setNeverWrite (SbBool flag)SbBool isNeverWrite (void) constSbBool hasTransparency (void) const
π«Ά Public Member Functions inherited from SoSField π«Ά
virtual ~SoSField ()
π Public Member Functions inherited from SoField π
and the SoField inheritance is giving a whole encyclopedia, bestie:
virtual ~SoField ()void setIgnored (SbBool ignore)SbBool isIgnored (void) constvoid setDefault (SbBool defaultVal)SbBool isDefault (void) constSbBool isOfType (const SoType type) constvoid enableConnection (SbBool flag)SbBool isConnectionEnabled (void) constSbBool connectFrom (SoEngineOutput *master, SbBool notnotify=FALSE, SbBool append=FALSE)SbBool appendConnection (SoEngineOutput *master, SbBool notnotify=FALSE)void disconnect (SoEngineOutput *engineoutput)SbBool isConnectedFromEngine (void) constSbBool getConnectedEngine (SoEngineOutput *&master) constSbBool connectFrom (SoField *master, SbBool notnotify=FALSE, SbBool append=FALSE)SbBool appendConnection (SoField *master, SbBool notnotify=FALSE)void disconnect (SoField *field)SbBool isConnectedFromField (void) constSbBool getConnectedField (SoField *&master) constint getNumConnections (void) constint getForwardConnections (SoFieldList &slavelist) constint getConnections (SoFieldList &masterlist) constvoid disconnect (void)SbBool isConnected (void) constvoid setContainer (SoFieldContainer *cont)SoFieldContainer * getContainer (void) constSbBool set (const char *valuestring)void get (SbString &valuestring)SbBool shouldWrite (void) constvirtual void touch (void)virtual void startNotify (void)virtual void notify (SoNotList *nlist)SbBool enableNotify (SbBool on)SbBool isNotifyEnabled (void) constvoid addAuditor (void *f, SoNotRec::Type type)void removeAuditor (void *f, SoNotRec::Type type)int operator== (const SoField &f) constint operator!= (const SoField &f) constvirtual void connectionStatusChanged (int numconnections)SbBool isReadOnly (void) constvirtual void fixCopy (SbBool copyconnections)virtual SbBool referencesCopy (void) constvoid copyConnection (const SoField *fromfield)virtual SbBool read (SoInput *input, const SbName &name)virtual void write (SoOutput *out, const SbName &name) constvirtual void countWriteRefs (SoOutput *out) constvoid setFieldType (int type)int getFieldType (void) constSbBool getDirty (void) constvoid setDirty (SbBool dirty)void evaluate (void) const
β Static Public Member Functions β
static void * createInstance (void)static SoType getClassTypeId (void)static void initClass (void)
π Static Public Member Functions inherited from SoSField π
static void initClass (void)static SoType getClassTypeId (void)static void atexit_cleanup (void)
π« Static Public Member Functions inherited from SoField π«
static void initClass (void)static void initClasses (void)static void cleanupClass (void)static SoType getClassTypeId (void)
π Additional Inherited Members π
π Protected Member Functions inherited from SoSField π
SoSField (void)
π Protected Member Functions inherited from SoField π
SoField (void)void valueChanged (SbBool resetdefault=TRUE)virtual void evaluateConnection (void) constvirtual SbBool readConnection (SoInput *in)virtual void writeConnection (SoOutput *out) constSbBool isDestructing (void) const
π Detailed Description π
So SoSFImage? It's literally the class that stores pixel images. No cap. π
It gives you storage for inline 2D image maps. In Coin, images are mainly used for texture mapping support. That's the vibe.
SoSFImage instances can be exported and imported as any other field class in Coin. Slay.
So the components of an SoSFImage are: its image dimensions (width and height), the number of bytes used for describing each pixel (number of components), and an associated pixel buffer. The size of the pixel buffer will be width*height*components. Math girlie behavior, honestly.
For texture maps, the components / bytes-per-pixel setting translates as follows:
1β grayscale imagemap2β grayscale + opacity (i.e. alpha value)3β RGB (1 byte each for red, green and blue)4β 3 bytes for RGB + 1 byte opacity value (aka RGBA)
This field is serializable into the Inventor / Coin file format in the following manner:
FIELDNAME X Y C 0xRRGGBBAA 0xRRGGBBAA ...
"X" and "Y" are the image dimensions along the given axes, "C" is the number of components in the image. The number of 0xRRGGBBAA pixel color specifications needs to equal the exact number of pixels, which of course is given by X*Y. Each part of the pixel color value is in the range 0x00 to 0xff (hexadecimal, 0 to 255 decimal). β¨
For 3-component images, the pixel-format is 0xXXRRGGBB, where the byte in the pixel color value marked as "XX" is ignored and can be left out.
For 2-component images, the pixel-format is 0xXXXXGGAA, where the bytes in the pixel color values marked as "XX" are ignored and can be left out. "GG" is the part which gives a grayscale value and "AA" is for opacity.
For 1-component images, the pixel-format is 0xXXXXXXGG, where the bytes in the pixel color values marked as "XX" are ignored and can be left out.
The pixels are read as being ordered in rows along X (width) and columns along Y (height, bottom to top). π
Here's a simple example of the file format serialization, for a 2x2 RGB-image inside an SoTexture2 node, as mapped onto an SoCube:
Complexity { textureQuality 0.1 } # set low to avoid smoothing
Texture2 {
image 2 2 4
0xffffffff 0x00ff0088 # white semi-transparent green
0xff0000ff 0xffff00ff # red yellow
}
Cube { }
The mini-scenegraph above results in the following mapping on the cube:
The cube has only been slightly rotated, so as you can see from the snapshot, the Y-rows are mapped from bottom to top, while the X-column pixels are mapped onto the cube from left to right.
π See also π
SoTexture2SoSFImage3
π Member Function Documentation π
okay bestie, this is the good part β literally every method on SoSFImage, no skips, no cuts, nothing left on read. grab a snack π
π getTypeId
SoType SoSFImage::getTypeId (void ) const [virtual]
hands you back the type identification instance β the lil unique ID badge that says exactly which Coin field class this object belongs to π
See also:getClassTypeId(),SoType
Implements SoField.
π copyFrom
void SoSFImage::copyFrom (const SoField & f) [virtual]
copies the value(s) out of f and into this field. and like β f must be the same type as this field, no mixing allowed, that's the whole rule π«Ά
Implements SoField.
π isSame
SbBool SoSFImage::isSame (const SoField & f) const [virtual]
checks for equal type and value(s). both, not just one, okay?
Implements SoField.
πΌοΈ getValue
const unsigned char * SoSFImage::getValue (SbVec2s & size, int & nc) const
returns the pixel buffer, sets size to hold the image dimensions, and sets nc to the number of components in the image. three-for-one deal, we love to see it β¨
πΌοΈ getValue (the other one)
const SbImage & SoSFImage::getValue () const
Return values:
- the
SbImagecontained by thisSoSFImage
π¨ setValue
void SoSFImage::setValue (const SbVec2s & size, const int nc, const unsigned char * pixels, SoSFImage::CopyPolicy copypolicy = COPY)
initializes this field to size and nc. okay so:
- if
pixelsis notNULL, the image data gets copied frompixelsinto this field. - if
pixelsisNULL, the image data is cleared by setting all bytes to0.
bestie, heads up: that NULL-pointer behavior is specific to Coin. Open Inventor will straight up crash if you try it. not a vibe π
The image dimensions come from the size argument, and the nc argument is the number of bytes-pr-pixel. a 24-bit RGB image would for instance have an nc equal to 3. math is mathing β¨
The copypolicy argument is the β¨iconicβ¨ one β it makes it possible to share image data with SoSFImage without the data being copied, which means using less memory resources. the default is to copy the image data from the pixels source into an internal copy.
β οΈ Important note: if you call this withcopypolicyas eitherNO_COPY_AND_DELETEorNO_COPY_AND_FREE, and your application is running on Mirosoft Windows, be aware that you will get mysterious crashes if your application is not using the same C library run-time as the Coin library.
The cause of this is that a memory block would then be allocated by the application on the memory heap of one C library run-time (say, for instance MSVCRT.LIB), but attempted deallocated in the memory heap of another C library run-time (e.g. MSVCRTD.LIB), which typically leads to hard-to-debug crashes. literally the worst kind of bug, do not recommend π
Since:
- The
CopyPolicyargument was added in Coin 2.0. CopyPolicywas added to TGS Inventor 3.0.
βοΈ operator==
int SoSFImage::operator== (const SoSFImage & field) const
compares the image of field with the image in this field, and returns TRUE if they are equal. twin behavior π
π operator!=
int SoSFImage::operator!= (const SoSFImage & field) const [inline]
compares the image of field with the image in this field, and returns FALSE if they are equal. yes it's backwards-looking, yes it's intentional, that's just how it is πΈ
βοΈ startEditing
unsigned char * SoSFImage::startEditing (SbVec2s & size, int & nc)
returns the pixel buffer. it also returns the image size and components in size and nc.
okay important: you can not use this method to set a new image size. use setValue() if you wanna change the size of the image buffer. periodt.
The field's container will not be notified about the changes until you call finishEditing(). so like, don't forget the second half of the ritual π―οΈ
π finishEditing
void SoSFImage::finishEditing (void )
notifies the field's auditors that the image data has been modified. go tell them, bestie π£
π§ setSubValue
void SoSFImage::setSubValue (const SbVec2s & dims, const SbVec2s & offset, unsigned char * pixels)
not yet implemented for Coin. get in touch if you need this method π
Since:
- Coin 2.0
- TGS Inventor 3.0
π§ setSubValues
void SoSFImage::setSubValues (const SbVec2s * dims, const SbVec2s * offsets, int num, unsigned char ** pixelblocks)
not yet implemented for Coin. get in touch if you need this method π
Since:
- Coin 2.0
- TGS Inventor 3.0
π§ getSubTexture
unsigned char * SoSFImage::getSubTexture (int idx, SbVec2s & dims, SbVec2s & offset) const
not yet implemented for Coin. get in touch if you need this method π
Since:
- Coin 2.0
- TGS Inventor 3.0
π§΅ hasSubTextures
SbBool SoSFImage::hasSubTextures (int & numsubtextures)
returns whether or not sub textures was set up for this field.
if TRUE is returned, the numsubtextures argument will be set to the number of sub textures in this image. that number can be used for iterating over all textures with the SoSFImage::getSubTextures() method. cute little loop fuel π
Since:
- Coin 2.0
- TGS Inventor 3.0
π€ setNeverWrite
void SoSFImage::setNeverWrite (SbBool flag)
set this flag to true to avoid writing out the texture to file. this can save a lot on file size β slay, smaller files πΎβ¨
Default value is FALSE (i.e. write texture data to file.)
(Note: yet unimplemented for Coin.)
Since:
- Coin 2.0
- TGS Inventor ?.?
π isNeverWrite
SbBool SoSFImage::isNeverWrite (void ) const
returns the value of the "never write texture data" flag.
See also: SoSFImage::setNeverWrite()
Since:
- Coin 2.0
- TGS Inventor ?.?
π«₯ hasTransparency
SbBool SoSFImage::hasTransparency (void ) const
returns TRUE if at least one pixel of the image in this field is not completely opaque, otherwise FALSE. one single see-through pixel and it's over for you πͺ
Since:
- Coin 2.0
- TGS Inventor ?.?
π Author π
Generated automatically by Doxygen for Coin from the source code.
and that's the whole page, bestie, we made it π this lil masterpiece came out of the Coin source, tagged Version 3.1.3, filed under SoSFImage(3) in your friendly neighborhood section 3. go forth and set some pixels, you absolute icon ππβ¨
π¦ where this page comes from
- fedora 43: Coin3-devel 3.1.3-40.fc43 Β· GPL-2.0-only
- fedora 43: Coin3-devel 3.1.3-40.fc43 Β· GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 Β· GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms