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() const
00356 {
00357 return m_dataType;
00358 }
00359
00360 void setCompressedInternalFormat(uint8_t intFormat) {m_compressedInternalFormat = intFormat;};
00361 uint8_t getCompressedInternalFormat() const
00362 {
00363 return m_compressedInternalFormat;
00364 }
00365
00366
00367
00368
00369
00370 bool copy(const SbRasterImage& subimage, const SbVec2i32& destPos = SbVec2i32(0, 0));
00371
00372
00373
00374
00375 bool copy(const SbRasterImage& subimage, const SbVec2i32& destPos, const SbVec2i32& sourcePos, const SbVec2i32& sourceSize);
00376
00377 private:
00378
00382 int getDataTypeSizeInBytes() const;
00383
00384 private:
00385
00386 void commonConstructor( const SbVec2i32 &size, Components components, SbDataType::DataType dataType,
00387 SoBufferObject* bufferObject );
00388
00389 SbVec2i32 m_size;
00390 Components m_components;
00395 mutable unsigned char* m_buffer;
00399 SoRef<SoBufferObject> m_bufferObject;
00403 mutable SoRef<SoCpuBufferObject> m_cpuBufferObject;
00404 CopyPolicy m_copy;
00405 int m_numMipmaps;
00406 uint8_t m_compressedInternalFormat;
00407
00408 SbDataType::DataType m_dataType;
00409 };
00410
00411 #ifdef _WIN32
00412 #pragma warning(pop)
00413 #endif
00414
00415 inline SbRasterImage::CopyPolicy
00416 SbRasterImage::getCopyPolicy() const
00417 {
00418 return m_copy;
00419 }
00420
00421 #endif
00422
00423
00424