Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SbRasterImage.h
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-2023 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : C. OGNIER (Jun 2003)
22**=======================================================================*/
23
24#ifndef _SBRASTERIMAGE_
25#define _SBRASTERIMAGE_
26
27
28#include <SoDeprecationRules.h>
29#include <Inventor/SbLinear.h>
30#include <Inventor/sys/SoGLType.h>
31#include <Inventor/SbDataType.h>
32#include <Inventor/devices/SoBufferObject.h>
33#include <Inventor/devices/SoCpuBufferObject.h>
34
35#ifdef _WIN32
36#pragma warning(push)
37#pragma warning(disable:4251)
38#endif
39
57
58
59public:
60
68 UNKNOWN = -1,
69
74
79
83 RGB = 3, // The default
84
89
94 RGBE = 5
95 };
96
97
121
122
127
161 SbRasterImage( const SbVec2i32 &size, Components components,
162 SoBufferObject* bufferObject );
163
167 virtual ~SbRasterImage();
168
176 void setSize(const SbVec2s& size);
177
183 void setSize_i32(const SbVec2i32& size);
184
189
194
200
206
213 int getComponentsSize() const;
214
222
256 void setBuffer(SoBufferObject* bufferObject);
257
277
282 int getNumMipmaps() {return m_numMipmaps;};
283
288
298
299#if 1 SoDEPRECATED
304 SbRasterImage( const SbVec2s &size, Components components,
305 const unsigned char *bytes, CopyPolicy copy=COPY );SoDEPRECATED
310 SbRasterImage( const SbVec2i32 &size, Components components,
311 const unsigned char *bytes, CopyPolicy copy=COPY );
312SoDEPRECATED
321 void setBuffer(unsigned char* buffer, CopyPolicy copy = COPY);
322 SoDEPRECATED
329 unsigned char* getBuffer() const;
330
331#endif
333private:
334
335#if 1 SoDEPRECATED
340 SbRasterImage( const SbVec2i32 &size, Components components, SbDataType::DataType dataType,
341 const void *bytes, CopyPolicy copy=COPY );
342
343#endif
348 SbRasterImage( const SbVec2i32 &size, Components components, SbDataType::DataType dataType,
349 SoBufferObject* bufferObject );
350
351
352 void setNumMipmaps(int nmm) {m_numMipmaps = nmm;};
353
354 void setDataType(SbDataType::DataType dataType) {m_dataType = dataType;};
355 SbDataType::DataType getDataType() const
356 {
357 return m_dataType;
358 }
359
360 void setCompressedInternalFormat(uint8_t intFormat) {m_compressedInternalFormat = intFormat;};
361 uint8_t getCompressedInternalFormat() const
362 {
363 return m_compressedInternalFormat;
364 }
365
366 /*
367 * Copy a sub image inside this image at the given position.
368 * If the the size of the sub image exceeds this image, only the part that fits will be copied.
369 */
370 bool copy(const SbRasterImage& subimage, const SbVec2i32& destPos = SbVec2i32(0, 0));
371 /*
372 * Copy a a portion of a sub image inside this image at the given position.
373 * If the the portion exceeds this image, only the part that fits will be copied.
374 */
375 bool copy(const SbRasterImage& subimage, const SbVec2i32& destPos, const SbVec2i32& sourcePos, const SbVec2i32& sourceSize);
376
377private:
378
382 int getDataTypeSizeInBytes() const;
383
384private:
385
386 void commonConstructor( const SbVec2i32 &size, Components components, SbDataType::DataType dataType,
387 SoBufferObject* bufferObject );
388
389 SbVec2i32 m_size;
390 Components m_components;
395 mutable unsigned char* m_buffer;
399 SoRef<SoBufferObject> m_bufferObject;
403 mutable SoRef<SoCpuBufferObject> m_cpuBufferObject;
404 CopyPolicy m_copy;
405 int m_numMipmaps;
406 uint8_t m_compressedInternalFormat;
407
408 SbDataType::DataType m_dataType;
409};
410
411#ifdef _WIN32
412#pragma warning(pop)
413#endif
414
417{
418 return m_copy;
419}
420
421#endif
422
423
DataType
Supported Data type.
Definition SbDataType.h:64
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Class encapsulat...
SbBool removeAlphaChannel()
Removes the Alpha channel from the current raster image.
SoBufferObject * getBufferObject() const
Returns the pixel buffer of the raster image.
void setSize(const SbVec2s &size)
Sets the raster image size in pixels.
CopyPolicy
Copy policy.
@ COPY
Open Inventor will make a copy of the data (default).
@ NO_COPY_AND_DELETE
Passed buffer used, SbRasterImage will delete.
@ NO_COPY_AND_FREE
Passed buffer used, SbRasterImage will free.
@ NO_COPY
Passed buffer used , user will delete .
int getComponentsSize() const
Returns the size in bytes of each pixel in the image.
SoDEPRECATED SbRasterImage(const SbVec2i32 &size, Components components, const unsigned char *bytes, CopyPolicy copy=COPY)
Constructor that initializes with a large image.
SbRasterImage()
Constructor that creates an empty image.
CopyPolicy getCopyPolicy() const
Returns the current buffer copy policy.
void setBuffer(SoBufferObject *bufferObject)
Sets the pixel buffer of the raster image.
void setComponents(SbRasterImage::Components comp)
Sets the number of components in each pixel of the raster image.
Components
Components type.
@ RGB
Number of components 3 (RGB) (default).
@ UNKNOWN
Unknown number of components.
@ LUMINANCE
Number of components 1 (luminance).
@ RGBE
Number of components 4 (RGBE).
@ RGB_TRANSPARENCY
Number of components 4 (RGB + transparency).
@ LUMINANCE_TRANSPARENCY
Number of components 2 (luminance + transparency).
virtual ~SbRasterImage()
Destructor.
SbRasterImage::Components getComponents() const
Returns the number of components of each pixel as an enum.
SoDEPRECATED SbRasterImage(const SbVec2s &size, Components components, const unsigned char *bytes, CopyPolicy copy=COPY)
Constructor that initializes with an image.
SbVec2i32 getSize_i32() const
Returns the raster image size in pixels for large images.
SoDEPRECATED unsigned char * getBuffer() const
Returns the pixel buffer of the raster image.
int getComponentsCount() const
Returns the number of components of each pixel.
SbVec2s getSize() const
Returns the raster image size in pixels.
SoDEPRECATED void setBuffer(unsigned char *buffer, CopyPolicy copy=COPY)
Sets the pixel buffer of the raster image.
SbRasterImage(const SbVec2i32 &size, Components components, SoBufferObject *bufferObject)
Constructor that initializes with an image.
void setSize_i32(const SbVec2i32 &size)
Sets the raster image size in pixels.
int getNumMipmaps()
Returns the number of mipmaps contained by the buffer.
2D vector class.
Definition SbVec.h:517
2D vector class.
Definition SbVec.h:700
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
Smart pointer for any class inheriting SoRefCounter.
Definition SoRef.h:90
int SbBool
Boolean type.
Definition SbBase.h:87