00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SBRASTERIMAGE_
00025 #define _SBRASTERIMAGE_
00026
00027
00028 #include <SoDeprecationRules.h>
00029 #include <Inventor/SbLinear.h>
00030 #include <Inventor/sys/SoGLType.h>
00031 #include <Inventor/SbDataType.h>
00032 #include <Inventor/devices/SoBufferObject.h>
00033 #include <Inventor/devices/SoCpuBufferObject.h>
00034
00035 #ifdef _WIN32
00036 #pragma warning(push)
00037 #pragma warning(disable:4251)
00038 #endif
00039
00056 class SbRasterImage {
00057
00058
00059 public:
00060
00064 enum Components {
00068 UNKNOWN = -1,
00069
00073 LUMINANCE = 1,
00074
00078 LUMINANCE_TRANSPARENCY = 2,
00079
00083 RGB = 3,
00084
00088 RGB_TRANSPARENCY = 4,
00089
00094 RGBE = 5
00095 };
00096
00097
00101 enum CopyPolicy {
00105 COPY = 0,
00109 NO_COPY = 1,
00114 NO_COPY_AND_DELETE = 2,
00119 NO_COPY_AND_FREE = 3
00120 };
00121
00122
00126 SbRasterImage();
00127
00161 SbRasterImage( const SbVec2i32 &size, Components components,
00162 SoBufferObject* bufferObject );
00163
00167 virtual ~SbRasterImage();
00168
00176 void setSize(const SbVec2s& size);
00177
00183 void setSize_i32(const SbVec2i32& size);
00184
00188 SbVec2s getSize() const;
00189
00193 SbVec2i32 getSize_i32() const;
00194
00199 void setComponents(SbRasterImage::Components comp);
00200
00205 SbRasterImage::Components getComponents() const;
00206
00213 int getComponentsSize() const;
00214
00221 int getComponentsCount() const;
00222
00256 void setBuffer(SoBufferObject* bufferObject);
00257
00276 SoBufferObject* getBufferObject() const;
00277
00282 int getNumMipmaps() {return m_numMipmaps;};
00283
00287 CopyPolicy getCopyPolicy() const;
00288
00297 SbBool removeAlphaChannel();
00298
00299 #if 1 SoDEPRECATED
00304 SbRasterImage( const SbVec2s &size, Components components,
00305 const unsigned char *bytes, CopyPolicy copy=COPY );SoDEPRECATED
00310 SbRasterImage( const SbVec2i32 &size, Components components,
00311 const unsigned char *bytes, CopyPolicy copy=COPY );
00312 SoDEPRECATED
00321 void setBuffer(unsigned char* buffer, CopyPolicy copy = COPY);
00322 SoDEPRECATED
00329 unsigned char* getBuffer() const;
00330
00331 #endif
00333 private:
00334
00335 #if 1 SoDEPRECATED
00340 SbRasterImage( const SbVec2i32 &size, Components components, SbDataType::DataType dataType,
00341 const void *bytes, CopyPolicy copy=COPY );
00342
00343 #endif
00348 SbRasterImage( const SbVec2i32 &size, Components components, SbDataType::DataType dataType,
00349 SoBufferObject* bufferObject );
00350
00351
00352 void setNumMipmaps(int nmm) {m_numMipmaps = nmm;};
00353
00354 void setDataType(SbDataType::DataType dataType) {m_dataType = dataType;};
00355 SbDataType::DataType getDataType() {return m_dataType;};
00356
00357 void setCompressedInternalFormat(uint8_t intFormat) {m_compressedInternalFormat = intFormat;};
00358 uint8_t getCompressedInternalFormat() {return m_compressedInternalFormat;};
00359
00360
00361
00362
00363
00364 bool copy(const SbRasterImage& subimage, const SbVec2i32& destPos = SbVec2i32(0, 0));
00365
00366
00367
00368
00369 bool copy(const SbRasterImage& subimage, const SbVec2i32& destPos, const SbVec2i32& sourcePos, const SbVec2i32& sourceSize);
00370
00371 private:
00372
00376 int getDataTypeSizeInBytes() const;
00377
00378 private:
00379
00380 void commonConstructor( const SbVec2i32 &size, Components components, SbDataType::DataType dataType,
00381 SoBufferObject* bufferObject );
00382
00383 SbVec2i32 m_size;
00384 Components m_components;
00389 mutable unsigned char* m_buffer;
00393 SoRef<SoBufferObject> m_bufferObject;
00397 mutable SoRef<SoCpuBufferObject> m_cpuBufferObject;
00398 CopyPolicy m_copy;
00399 int m_numMipmaps;
00400 uint8_t m_compressedInternalFormat;
00401
00402 SbDataType::DataType m_dataType;
00403 };
00404
00405 #ifdef _WIN32
00406 #pragma warning(pop)
00407 #endif
00408
00409 inline SbRasterImage::CopyPolicy
00410 SbRasterImage::getCopyPolicy() const
00411 {
00412 return m_copy;
00413 }
00414
00415 #endif
00416
00417
00418