Changeset 13041 for OpenSceneGraph/trunk/include/osg/Image
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osg/Image (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osg/Image
r13025 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 94 94 95 95 #ifndef GL_OES_compressed_ETC1_RGB8_texture 96 #define GL_ETC1_RGB8_OES 0x8D64 96 #define GL_ETC1_RGB8_OES 0x8D64 97 97 #endif 98 98 … … 109 109 110 110 Image(); 111 111 112 112 /** Copy constructor using CopyOp to manage deep vs shallow copy. */ 113 113 Image(const Image& image,const CopyOp& copyop=CopyOp::SHALLOW_COPY); … … 130 130 void setFileName(const std::string& fileName); 131 131 inline const std::string& getFileName() const { return _fileName; } 132 132 133 133 enum WriteHint { 134 134 NO_PREFERENCE, … … 136 136 EXTERNAL_FILE 137 137 }; 138 138 139 139 void setWriteHint(WriteHint writeHint) { _writeHint = writeHint; } 140 140 WriteHint getWriteHint() const { return _writeHint; } 141 141 142 142 enum AllocationMode { 143 143 NO_DELETE, … … 145 145 USE_MALLOC_FREE 146 146 }; 147 147 148 148 /** Set the method used for deleting data once it goes out of scope. */ 149 149 void setAllocationMode(AllocationMode mode) { _allocationMode = mode; } … … 157 157 GLenum pixelFormat,GLenum type, 158 158 int packing=1); 159 160 159 160 161 161 /** Set the image dimensions, format and data. */ 162 162 virtual void setImage(int s,int t,int r, … … 166 166 AllocationMode mode, 167 167 int packing=1, int rowLength=0); 168 168 169 169 /** Read pixels from current frame buffer at specified position and size, using glReadPixels. 170 170 * Create memory for storage if required, reuse existing pixel coords if possible. … … 172 172 virtual void readPixels(int x,int y,int width,int height, 173 173 GLenum pixelFormat,GLenum type); 174 174 175 175 176 176 /** Read the contents of the current bound texture, handling compressed pixelFormats if present. … … 196 196 197 197 198 enum Origin 198 enum Origin 199 199 { 200 200 BOTTOM_LEFT, 201 201 TOP_LEFT 202 202 }; 203 203 204 204 /** Set the origin of the image. 205 205 * The default value is BOTTOM_LEFT and is consistent with OpenGL. … … 208 208 * to handle this origin position. */ 209 209 void setOrigin(Origin origin) { _origin = origin; } 210 210 211 211 /** Get the origin of the image.*/ 212 212 Origin getOrigin() const { return _origin; } 213 213 214 214 215 215 /** Width of image. */ … … 218 218 /** Height of image. */ 219 219 inline int t() const { return _t; } 220 220 221 221 /** Depth of image. */ 222 222 inline int r() const { return _r; } … … 224 224 void setRowLength(int length); 225 225 inline int getRowLength() const { return _rowLength; } 226 226 227 227 void setInternalTextureFormat(GLint internalFormat); 228 228 inline GLint getInternalTextureFormat() const { return _internalTextureFormat; } 229 229 230 230 void setPixelFormat(GLenum pixelFormat); 231 231 inline GLenum getPixelFormat() const { return _pixelFormat; } 232 232 233 233 void setDataType(GLenum dataType); 234 inline GLenum getDataType() const { return _dataType; } 235 234 inline GLenum getDataType() const { return _dataType; } 235 236 236 void setPacking(unsigned int packing) { _packing = packing; } 237 237 inline unsigned int getPacking() const { return _packing; } … … 245 245 /** Get the pixel aspect ratio.*/ 246 246 inline float getPixelAspectRatio() const { return _pixelAspectRatio; } 247 247 248 248 /** Return the number of bits required for each pixel. */ 249 249 inline unsigned int getPixelSizeInBits() const { return computePixelSizeInBits(_pixelFormat,_dataType); } … … 258 258 /** Return the number of bytes each image (_s*_t) of pixels occupies. */ 259 259 inline unsigned int getImageSizeInBytes() const { return getRowSizeInBytes()*_t; } 260 261 /** Return the number of bytes between each successive image. 260 261 /** Return the number of bytes between each successive image. 262 262 * Note, getImageSizeInBytes() will only equal getImageStepInBytes() when isDataContiguous() return true. */ 263 263 inline unsigned int getImageStepInBytes() const { return getRowStepInBytes()*_t; } … … 276 276 * take care to access the data per row rather than treating the whole data as a single block. */ 277 277 inline unsigned char* data() { return _data; } 278 278 279 279 /** Raw const image data. 280 280 * Note, data in successive rows may not be contiguous, isDataContiguous() return false then you should … … 287 287 return _data+(column*getPixelSizeInBits())/8+row*getRowStepInBytes()+image*getImageSizeInBytes(); 288 288 } 289 289 290 290 inline const unsigned char* data(int column, int row=0,int image=0) const 291 291 { … … 319 319 protected: 320 320 321 321 322 322 void assign(); 323 323 324 324 const osg::Image* _image; 325 325 int _rowNum; … … 342 342 /** Flip the image horizontally, around s dimension. */ 343 343 void flipHorizontal(); 344 344 345 345 /** Flip the image vertically, around t dimension. */ 346 346 void flipVertical(); … … 379 379 /** Send offsets into data. It is assumed that first mipmap offset (index 0) is 0.*/ 380 380 inline void setMipmapLevels(const MipmapDataType& mipmapDataVector) { _mipmapData = mipmapDataVector; } 381 381 382 382 inline const MipmapDataType& getMipmapLevels() const { return _mipmapData; } 383 383 … … 390 390 return 0; 391 391 }; 392 392 393 393 inline unsigned char* getMipmapData(unsigned int mipmapLevel) 394 394 { … … 407 407 virtual bool isImageTranslucent() const; 408 408 409 /** Set the optional PixelBufferObject used to map the image memory efficiently to graphics memory. */ 409 /** Set the optional PixelBufferObject used to map the image memory efficiently to graphics memory. */ 410 410 void setPixelBufferObject(PixelBufferObject* buffer) { setBufferObject(buffer); } 411 411 … … 465 465 AllocationMode _allocationMode; 466 466 unsigned char* _data; 467 467 468 468 void deallocateData(); 469 469 470 470 void setData(unsigned char* data,AllocationMode allocationMode); 471 471 472 472 MipmapDataType _mipmapData; 473 473 474 474 ref_ptr<PixelBufferObject> _bufferObject; 475 475 };
