Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoMFImage.h
Go to the documentation of this file.
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24
25#ifndef _SO_MF_IMAGE_
26#define _SO_MF_IMAGE_
27
29#include <Inventor/SbLinear.h>
30#include <Inventor/SbPList.h>
31
33//
34// SoMFImage subclass of SoMField.
35//
37
100class SoMFImage : public SoMField {
101
102 // Uses only some of the standard field stuff
103 // (because there is no SbImage type):
107
108 public:
136
137 // getValue returns the size, number of components and a constant
138 // pointer to the image.
139
146 const unsigned char *getValue(SbVec2s &size, int &nc) const;
147
148 // setValue copies the image given to it into internal storage.
149 // See startEditing() for a way of avoiding the copy if you are
150 // doing a getValue() followed immediately by a setValue(). Set
151 // 'copy' to NO_COPY or NO_COPY_AND_DELETE to pass directly the
152 // pointer on the images. Otherwise, the buffer 'bytes' will be
153 // copied. If copy is set to COPY or NO_COPY_AND_DELETE or
154 // NO_COPY_AND_FREE, this object will delete the buffer when
155 // required. If a NULL pointer is passed, a new bloc is allocated
156 // according to the size and the number of components.
157
169 void setValue(const SbVec2s &size, int nc,
170 const unsigned char *bytes,
171 CopyPolicy copy = COPY);
172#ifdef NOTNOW
183 void setSubValue(const SbVec2s &subSize,
184 const SbVec2s &offset,
185 unsigned char *bytes);
186
197 void setSubValues(const SbVec2s *subSizes,
198 const SbVec2s *offsets,
199 int num, unsigned char **bytes);
203 int operator ==(const SoMFImage &f) const;
204
208 int operator !=(const SoMFImage &f) const
209 { return ! ((*this) == f); }
210
218 unsigned char *startEditing(SbVec2s &size, int &nc);
219
224 void finishEditing();
225
232 unsigned char *getSubTexture(int index, SbVec2s &size, SbVec2s &offset);
233
238 SbBool hasSubTextures(int &numSubTextures);
239#endif
247 void setNeverWrite(SbBool neverWrite);
248
253 { return neverWrite ; }
254
261
262 private:
263
264 static void initClass();
265 //
266 void resetSubTextures();
267
268 private:
269
270 // Width and height of image
271 SbVec2s size;
272
273 // Number of components per pixel
274 int numComponents;
275
276 // Array of pixels
277 unsigned char *bytes;
278
279 CopyPolicy copyPolicy;
280
281 // list of [subSize, offset, bytes]
282 // SbPList subTexList;
283 SbBool neverWrite;
284
285 // -1 = don't know yet, 0 = no transp, 1 = has transp
286 int m_hasTransparency;
287
288 // Reading and writing
289 virtual SbBool readValue(SoInput *in);
290 virtual void writeValue(SoOutput *out) const;
291};
292
293#endif /* _SO_MF_IMAGE_ */
294
#define SO_MFIELD_REQUIRED_HEADER(className)
Definition SoSubField.h:311
#define SO_MFIELD_CONSTRUCTOR_HEADER(className)
Definition SoSubField.h:320
#define SO__MFIELD_RW_HEADER(className)
Definition SoSubField.h:94
2D vector class.
Definition SbVec.h:700
int operator==(const SoField &f) const
Return TRUE if this field is of the same type and has the same value as f.
Definition SoField.h:510
int operator!=(const SoField &f) const
Return FALSE if this field is of the same type and has the same value as f.
Definition SoField.h:516
Used to read Open Inventor data files.
Definition SoInput.h:363
Field containing multiple 2D images.
Definition SoMFImage.h:100
void setValue(const SbVec2s &size, int nc, const unsigned char *bytes, CopyPolicy copy=COPY)
Sets the value of this field to be an image of the given size, with the given number of components,...
SbBool hasTransparency() const
Returns TRUE if the image contains any transparent pixels.
CopyPolicy
SoMFImage may be manipulating some large amounts of memory.
Definition SoMFImage.h:116
@ NO_COPY
Passed buffer used, user will delete.
Definition SoMFImage.h:124
@ NO_COPY_AND_DELETE
Passed buffer used, SoMFImage will delete.
Definition SoMFImage.h:129
@ NO_COPY_AND_FREE
Passed buffer used, SoMFImage will free.
Definition SoMFImage.h:134
@ COPY
Open Inventor will make a copy of the data (default)
Definition SoMFImage.h:120
void setNeverWrite(SbBool neverWrite)
Sets the "neverWrite" flag.
SbBool isNeverWrite()
Queries the "neverWrite" flag.
Definition SoMFImage.h:252
const unsigned char * getValue(SbVec2s &size, int &nc) const
Returns the pixels in the image as an array of unsigned chars.
Base class for all multiple-valued fields.
Definition SoMField.h:134
Used to write Open Inventor data files.
Definition SoOutput.h:185
int SbBool
Boolean type.
Definition SbBase.h:87