OpenSceneGraph 3.6.5
Image
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
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
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSG_IMAGE
15#define OSG_IMAGE 1
16
17#include <osg/BufferObject>
18#include <osg/Vec2>
19#include <osg/Vec3>
20#include <osg/Vec3i>
21#include <osg/Vec4>
22#include <osg/FrameStamp>
23#include <osg/StateAttribute>
24
25#include <string>
26#include <vector>
27
28#ifndef GL_VERSION_1_2
29 // 1.2 definitions...
30 #define GL_BGR 0x80E0
31 #define GL_BGRA 0x80E1
32 #define GL_UNSIGNED_BYTE_3_3_2 0x8032
33 #define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
34 #define GL_UNSIGNED_SHORT_5_6_5 0x8363
35 #define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
36 #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
37 #define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
38 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
39 #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
40 #define GL_UNSIGNED_INT_8_8_8_8 0x8035
41 #define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
42 #define GL_UNSIGNED_INT_10_10_10_2 0x8036
43 #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
44#endif
45
46#ifndef GL_COMPRESSED_ALPHA
47 #define GL_COMPRESSED_ALPHA 0x84E9
48 #define GL_COMPRESSED_LUMINANCE 0x84EA
49 #define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB
50 #define GL_COMPRESSED_INTENSITY 0x84EC
51 #define GL_COMPRESSED_RGB 0x84ED
52 #define GL_COMPRESSED_RGBA 0x84EE
53#endif
54
55
56#ifndef GL_ABGR_EXT
57#define GL_ABGR_EXT 0x8000
58#endif
59
60#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE)
61 #define GL_RED 0x1903
62 #define GL_GREEN 0x1904
63 #define GL_BLUE 0x1905
64 #define GL_DEPTH_COMPONENT 0x1902
65#endif
66
67#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE)
68 #define GL_STENCIL_INDEX 0x1901
69#endif
70
71#if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) || defined(OSG_GLES3_AVAILABLE) || defined(OSG_GL3_AVAILABLE)
72 #define GL_ALPHA4 0x803B
73 #define GL_ALPHA8 0x803C
74 #define GL_ALPHA12 0x803D
75 #define GL_ALPHA16 0x803E
76 #define GL_BITMAP 0x1A00
77 #define GL_COLOR_INDEX 0x1900
78 #define GL_INTENSITY12 0x804C
79 #define GL_INTENSITY16 0x804D
80 #define GL_INTENSITY 0x8049
81 #define GL_INTENSITY4 0x804A
82 #define GL_INTENSITY8 0x804B
83 #define GL_LUMINANCE12 0x8041
84 #define GL_LUMINANCE12_ALPHA4 0x8046
85 #define GL_LUMINANCE12_ALPHA12 0x8047
86 #define GL_LUMINANCE16 0x8042
87 #define GL_LUMINANCE16_ALPHA16 0x8048
88 #define GL_LUMINANCE4 0x803F
89 #define GL_LUMINANCE4_ALPHA4 0x8043
90 #define GL_LUMINANCE6_ALPHA2 0x8044
91 #define GL_LUMINANCE8 0x8040
92 #define GL_LUMINANCE8_ALPHA8 0x8045
93 #define GL_RGBA8 0x8058
94 #define GL_RGBA16 0x805B
95 #define GL_PACK_ROW_LENGTH 0x0D02
96#endif
97
98#ifndef GL_PACK_SKIP_IMAGES
99 #define GL_PACK_SKIP_IMAGES 0x806B
100 #define GL_PACK_IMAGE_HEIGHT 0x806C
101 #define GL_UNPACK_SKIP_IMAGES 0x806D
102 #define GL_UNPACK_IMAGE_HEIGHT 0x806E
103#endif
104
105#ifndef GL_OES_compressed_ETC1_RGB8_texture
106 #define GL_ETC1_RGB8_OES 0x8D64
107#endif
108
109#ifndef GL_ARB_ES3_compatibility
110 #define GL_COMPRESSED_RGB8_ETC2 0x9274
111 #define GL_COMPRESSED_SRGB8_ETC2 0x9275
112 #define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
113 #define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
114 #define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
115 #define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
116 #define GL_COMPRESSED_R11_EAC 0x9270
117 #define GL_COMPRESSED_SIGNED_R11_EAC 0x9271
118 #define GL_COMPRESSED_RG11_EAC 0x9272
119 #define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273
120#endif
121
122#ifndef GL_KHR_texture_compression_astc_hdr
123#define GL_KHR_texture_compression_astc_hdr 1
124#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
125#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
126#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
127#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
128#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
129#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
130#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
131#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
132#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
133#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
134#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
135#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
136#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
137#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
138#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
139#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
140#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
141#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
142#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
143#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
144#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
145#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
146#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
147#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
148#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
149#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
150#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
151#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
152#endif /* GL_KHR_texture_compression_astc_hdr */
153
154#ifndef GL_DEPTH_COMPONENT
155#define GL_DEPTH_COMPONENT 0x1902
156#endif
157
158#ifndef GL_VERSION_1_4
159#define GL_DEPTH_COMPONENT16 0x81A5
160#define GL_DEPTH_COMPONENT24 0x81A6
161#define GL_DEPTH_COMPONENT32 0x81A7
162#endif
163
164#ifndef GL_DEPTH_COMPONENT32F
165#define GL_DEPTH_COMPONENT32F 0x8CAC
166#endif
167
168#ifndef GL_DEPTH_COMPONENT32F_NV
169#define GL_DEPTH_COMPONENT32F_NV 0x8DAB
170#endif
171
172namespace osg {
173
174// forward declare
175class NodeVisitor;
176
179{
180
181 public :
182
184
186 Image(const Image& image,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
187
188 virtual Object* cloneType() const { return new Image(); }
189 virtual Object* clone(const CopyOp& copyop) const { return new Image(*this,copyop); }
190 virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const Image*>(obj)!=0; }
191 virtual const char* libraryName() const { return "osg"; }
192 virtual const char* className() const { return "Image"; }
193
194 virtual osg::Image* asImage() { return this; }
195 virtual const osg::Image* asImage() const { return this; }
196
197 virtual const GLvoid* getDataPointer() const { return data(); }
198 virtual unsigned int getTotalDataSize() const { return getTotalSizeInBytesIncludingMipmaps(); }
199
201 virtual int compare(const Image& rhs) const;
202
203 void setFileName(const std::string& fileName);
204 inline const std::string& getFileName() const { return _fileName; }
205
211
212 void setWriteHint(WriteHint writeHint) { _writeHint = writeHint; }
214
220
223
226
227
229 virtual void allocateImage(int s,int t,int r,
230 GLenum pixelFormat,GLenum type,
231 int packing=1);
232
233
235 virtual void setImage(int s,int t,int r,
236 GLint internalTextureformat,
237 GLenum pixelFormat,GLenum type,
238 unsigned char* data,
239 AllocationMode mode,
240 int packing=1, int rowLength=0);
241
245 virtual void readPixels(int x,int y,int width,int height,
246 GLenum pixelFormat, GLenum type, int packing=1);
247
248
252 virtual void readImageFromCurrentTexture(unsigned int contextID, bool copyMipMapsIfAvailable, GLenum type = GL_UNSIGNED_BYTE, unsigned int face = 0);
253
255 void swap(osg::Image& rhs);
256
258 void scaleImage(int s,int t,int r) { scaleImage(s,t,r, getDataType()); }
259
261 virtual void scaleImage(int s,int t,int r, GLenum newDataType);
262
270 virtual void copySubImage(int s_offset, int t_offset, int r_offset, const osg::Image* source);
271
272
278
284 void setOrigin(Origin origin) { _origin = origin; }
285
287 Origin getOrigin() const { return _origin; }
288
289
291 inline int s() const { return _s; }
292
294 inline int t() const { return _t; }
295
297 inline int r() const { return _r; }
298
299 void setRowLength(int length);
300 inline int getRowLength() const { return _rowLength; }
301
302 void setInternalTextureFormat(GLint internalFormat);
303 inline GLint getInternalTextureFormat() const { return _internalTextureFormat; }
304
305 void setPixelFormat(GLenum pixelFormat);
306 inline GLenum getPixelFormat() const { return _pixelFormat; }
307
308 void setDataType(GLenum dataType);
309 inline GLenum getDataType() const { return _dataType; }
310
311 void setPacking(unsigned int packing) { _packing = packing; }
312 inline unsigned int getPacking() const { return _packing; }
313
315 bool isCompressed() const;
316
318 inline void setPixelAspectRatio(float pixelAspectRatio) { _pixelAspectRatio = pixelAspectRatio; }
319
321 inline float getPixelAspectRatio() const { return _pixelAspectRatio; }
322
324 inline unsigned int getPixelSizeInBits() const { return computePixelSizeInBits(_pixelFormat,_dataType); }
325
328
332
334 inline unsigned int getImageSizeInBytes() const { return getRowSizeInBytes()*_t; }
335
338 inline unsigned int getImageStepInBytes() const { return getRowStepInBytes()*_t; }
339
341 inline unsigned int getTotalSizeInBytes() const { return getImageSizeInBytes()*_r; }
342
345
347 bool valid() const { return _s!=0 && _t!=0 && _r!=0 && _data!=0 && _dataType!=0; }
348
352 inline unsigned char* data() { return _data; }
353
357 inline const unsigned char* data() const { return _data; }
358
359 inline unsigned char* data(unsigned int column, unsigned int row = 0, unsigned int image = 0)
360 {
361 if (!_data) return NULL;
362 return _data+(column*getPixelSizeInBits())/8+row*getRowStepInBytes()+image*getImageSizeInBytes();
363 }
364
365 inline const unsigned char* data(unsigned int column, unsigned int row = 0, unsigned int image = 0) const
366 {
367 if (!_data) return NULL;
368 return _data+(column*getPixelSizeInBits())/8+row*getRowStepInBytes()+image*getImageSizeInBytes();
369 }
370
372 bool isDataContiguous() const { return _rowLength==0 || _rowLength==_s; }
373
376 {
377 public:
378 DataIterator(const Image* image);
381
383 void operator ++ ();
384
386 bool valid() const { return _currentPtr!=0; }
387
389 const unsigned char* data() const { return _currentPtr; }
390
392 unsigned int size() const { return _currentSize; }
393
394 protected:
395
396
397 void assign();
398
402 unsigned int _mipmapNum;
403 const unsigned char* _currentPtr;
404 unsigned int _currentSize;
405 };
406
408 Vec4 getColor(unsigned int s,unsigned t=0,unsigned r=0) const;
409
411 Vec4 getColor(const Vec2& texcoord) const { return getColor(Vec3(texcoord.x(),texcoord.y(),0.0f)); }
412
414 Vec4 getColor(const Vec3& texcoord) const;
415
417 void setColor(const osg::Vec4& color, unsigned int s, unsigned int t=0, unsigned int r=0);
418
420 void setColor(const osg::Vec4& color, const osg::Vec2& texcoord ) { setColor(color, osg::Vec3(texcoord, 0.0f)); }
421
423 void setColor(const osg::Vec4& color, const osg::Vec3& texcoord );
424
427
430
432 void flipDepth();
433
439 void ensureValidSizeForTexturing(GLint maxTextureSize);
440
441 static bool isPackedType(GLenum type);
442 static GLenum computePixelFormat(GLenum pixelFormat);
443 static GLenum computeFormatDataType(GLenum pixelFormat);
444
446 static osg::Vec3i computeBlockFootprint(GLenum pixelFormat);
447
449 static unsigned int computeBlockSize(GLenum pixelFormat, GLenum packing);
450 static unsigned int computeNumComponents(GLenum pixelFormat);
451 static unsigned int computePixelSizeInBits(GLenum pixelFormat,GLenum type);
452 static unsigned int computeRowWidthInBytes(int width,GLenum pixelFormat,GLenum type,int packing);
453 static unsigned int computeImageSizeInBytes(int width,int height, int depth, GLenum pixelFormat, GLenum type, int packing = 1, int slice_packing = 1, int image_packing = 1);
454 static int roudUpToMultiple(int s, int pack);
455 static int computeNearestPowerOfTwo(int s,float bias=0.5f);
456 static int computeNumberOfMipmapLevels(int s,int t = 1, int r = 1);
457
459 typedef std::vector< unsigned int > MipmapDataType;
460
461 inline bool isMipmap() const {return !_mipmapData.empty();};
462
463 unsigned int getNumMipmapLevels() const
464 {
465 return static_cast<unsigned int>(_mipmapData.size())+1;
466 };
467
469 inline void setMipmapLevels(const MipmapDataType& mipmapDataVector) { _mipmapData = mipmapDataVector; }
470
471 inline const MipmapDataType& getMipmapLevels() const { return _mipmapData; }
472
473 inline unsigned int getMipmapOffset(unsigned int mipmapLevel) const
474 {
475 if(mipmapLevel == 0)
476 return 0;
477 else if (mipmapLevel < getNumMipmapLevels())
478 return _mipmapData[mipmapLevel-1];
479 return 0;
480 };
481
482 inline unsigned char* getMipmapData(unsigned int mipmapLevel)
483 {
484 return _data+getMipmapOffset(mipmapLevel);
485 }
486
487 inline const unsigned char* getMipmapData(unsigned int mipmapLevel) const
488 {
489 return _data+getMipmapOffset(mipmapLevel);
490 }
491
494
496 virtual bool isImageTranslucent() const;
497
500
503
505 const PixelBufferObject* getPixelBufferObject() const { return dynamic_cast<const PixelBufferObject*>(getBufferObject()); }
506
508 virtual bool requiresUpdateCall() const { return false; }
509
511 virtual void update(NodeVisitor* /*nv*/) {}
512
518 {
519 virtual void operator () (osg::StateAttribute* attr, osg::NodeVisitor* nv);
520 };
521
523 virtual bool sendFocusHint(bool /*focus*/) { return false; }
524
526 virtual bool sendPointerEvent(int /*x*/, int /*y*/, int /*buttonMask*/) { return false; }
527
529 virtual bool sendKeyEvent(int /*key*/, bool /*keyDown*/) { return false; }
530
532 virtual void setFrameLastRendered(const osg::FrameStamp* /*frameStamp*/) {}
533
535 public:
537 virtual void operator()(osg::Image* image) = 0;
538 };
539
540 typedef std::vector< osg::ref_ptr<DimensionsChangedCallback> > DimensionsChangedCallbackVector;
541
544
545 protected :
546
547 virtual ~Image();
548
549 Image& operator = (const Image&) { return *this; }
550
552 {
553 for(DimensionsChangedCallbackVector::iterator i = _dimensionsChangedCallbacks.begin(); i != _dimensionsChangedCallbacks.end(); ++i)
554 {
555 (*i)->operator()(this);
556 }
557 }
558
559 std::string _fileName;
561
563
564 int _s, _t, _r;
568 GLenum _dataType;
569 unsigned int _packing;
571
573 unsigned char* _data;
574
576
577 void setData(unsigned char* data,AllocationMode allocationMode);
578
580
582};
583
584class Geode;
585
591
592template<class T> Geode* createGeodeForImage(const ref_ptr<T>& image) { return createGeodeForImage(image.get()); }
593
594
599extern OSG_EXPORT Geode* createGeodeForImage(Image* image, float s, float t);
600
601template<class T> Geode* createGeodeForImage(const ref_ptr<T>& image, float s, float t) { return createGeodeForImage(image.get(), s, t); }
602
603}
604
605#endif // __SG_IMAGE_H
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
Vec2f Vec2
Definition Vec2:21
Vec3f Vec3
Definition Vec3:21
OSG_EXPORT Geode * createGeodeForImage(Image *image)
Convenience function to be used by image loaders to generate a valid geode to return for readNode().
Vec4f Vec4
Definition Vec4:21
BufferObject * getBufferObject()
Definition BufferObject:529
BufferData()
Definition BufferObject:498
void setBufferObject(BufferObject *bufferObject)
Definition BufferObject:668
Deprecated.
Definition Callback:246
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Class which encapsulates the frame number, reference time and calendar time of specific frame,...
Definition FrameStamp:35
A Geode is a "geometry node", that is, a leaf node on the scene graph that can have "renderable thing...
Definition Geode:29
Image class for encapsulating the storage texture image data.
Definition Image:179
void setPixelBufferObject(PixelBufferObject *buffer)
Set the optional PixelBufferObject used to map the image memory efficiently to graphics memory.
Definition Image:499
bool valid() const
Return true if the Image represent a valid and usable imagery.
Definition Image:347
virtual const char * libraryName() const
return the name of the object's library.
Definition Image:191
virtual bool sendKeyEvent(int, bool)
Send key events to images that are acting as front ends to interactive surfaces such as a vnc or brow...
Definition Image:529
virtual bool isSameKindAs(const Object *obj) const
Definition Image:190
void deallocateData()
void flipHorizontal()
Flip the image horizontally, around s dimension.
virtual void readPixels(int x, int y, int width, int height, GLenum pixelFormat, GLenum type, int packing=1)
Read pixels from current frame buffer at specified position and size, using glReadPixels.
unsigned int getRowSizeInBytes() const
Return the number of bytes each row of pixels occupies once it has been packed.
Definition Image:327
void setRowLength(int length)
virtual Object * clone(const CopyOp &copyop) const
Clone an object, with Object* return type.
Definition Image:189
PixelBufferObject * getPixelBufferObject()
Get the PixelBufferObject.
Definition Image:502
unsigned int getNumMipmapLevels() const
Definition Image:463
virtual void update(NodeVisitor *)
update method for osg::Image subclasses that update themselves during the update traversal.
Definition Image:511
MipmapDataType _mipmapData
Definition Image:579
static bool isPackedType(GLenum type)
Origin
Definition Image:274
@ TOP_LEFT
Definition Image:276
@ BOTTOM_LEFT
Definition Image:275
Vec4 getColor(unsigned int s, unsigned t=0, unsigned r=0) const
Get the color value for specified texcoord.
void removeDimensionsChangedCallback(DimensionsChangedCallback *cb)
int s() const
Width of image.
Definition Image:291
void setInternalTextureFormat(GLint internalFormat)
Vec4 getColor(const Vec2 &texcoord) const
Get the color value for specified texcoord.
Definition Image:411
void setMipmapLevels(const MipmapDataType &mipmapDataVector)
Send offsets into data.
Definition Image:469
void setPacking(unsigned int packing)
Definition Image:311
const PixelBufferObject * getPixelBufferObject() const
Get the const PixelBufferObject.
Definition Image:505
int _r
Definition Image:564
unsigned int getImageStepInBytes() const
Return the number of bytes between each successive image.
Definition Image:338
int t() const
Height of image.
Definition Image:294
WriteHint
Definition Image:206
@ NO_PREFERENCE
Definition Image:207
@ STORE_INLINE
Definition Image:208
@ EXTERNAL_FILE
Definition Image:209
unsigned char * data(unsigned int column, unsigned int row=0, unsigned int image=0)
Definition Image:359
virtual unsigned int getTotalDataSize() const
Definition Image:198
virtual bool sendFocusHint(bool)
Hint whether to enable or disable focus to images acting as front ends to interactive surfaces such a...
Definition Image:523
void setDataType(GLenum dataType)
unsigned int getMipmapOffset(unsigned int mipmapLevel) const
Definition Image:473
AllocationMode getAllocationMode() const
Get the method used for deleting data once it goes out of scope.
Definition Image:225
void handleDimensionsChangedCallbacks()
Definition Image:551
virtual void readImageFromCurrentTexture(unsigned int contextID, bool copyMipMapsIfAvailable, GLenum type=GL_UNSIGNED_BYTE, unsigned int face=0)
Read the contents of the current bound texture, handling compressed pixelFormats if present.
static unsigned int computeImageSizeInBytes(int width, int height, int depth, GLenum pixelFormat, GLenum type, int packing=1, int slice_packing=1, int image_packing=1)
virtual void scaleImage(int s, int t, int r, GLenum newDataType)
Scale image to specified size and with specified data type.
virtual Object * cloneType() const
Clone the type of an object, with Object* return type.
Definition Image:188
GLenum getDataType() const
Definition Image:309
int _rowLength
Definition Image:565
static GLenum computeFormatDataType(GLenum pixelFormat)
void setOrigin(Origin origin)
Set the origin of the image.
Definition Image:284
unsigned int getPacking() const
Definition Image:312
AllocationMode
Definition Image:215
@ NO_DELETE
Definition Image:216
@ USE_MALLOC_FREE
Definition Image:218
@ USE_NEW_DELETE
Definition Image:217
static int computeNumberOfMipmapLevels(int s, int t=1, int r=1)
void ensureValidSizeForTexturing(GLint maxTextureSize)
Ensure image dimensions are a power of two.
int _t
Definition Image:564
unsigned int _packing
Definition Image:569
Origin getOrigin() const
Get the origin of the image.
Definition Image:287
virtual void copySubImage(int s_offset, int t_offset, int r_offset, const osg::Image *source)
Copy a source Image into a subpart of this Image at specified position.
float getPixelAspectRatio() const
Get the pixel aspect ratio.
Definition Image:321
Image(const Image &image, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Copy constructor using CopyOp to manage deep vs shallow copy.
void setData(unsigned char *data, AllocationMode allocationMode)
unsigned char * getMipmapData(unsigned int mipmapLevel)
Definition Image:482
static GLenum computePixelFormat(GLenum pixelFormat)
void setColor(const osg::Vec4 &color, unsigned int s, unsigned int t=0, unsigned int r=0)
Set the color value for specified texcoord.
unsigned int getTotalSizeInBytesIncludingMipmaps() const
Return the number of bytes the whole row/image/volume of pixels occupies, including all mip maps if i...
static unsigned int computeNumComponents(GLenum pixelFormat)
unsigned int getTotalSizeInBytes() const
Return the number of bytes the whole row/image/volume of pixels occupies.
Definition Image:341
DimensionsChangedCallbackVector _dimensionsChangedCallbacks
Definition Image:581
virtual const GLvoid * getDataPointer() const
Definition Image:197
unsigned char * _data
Definition Image:573
bool isCompressed() const
Return true of the pixel format is an OpenGL compressed pixel format.
virtual const osg::Image * asImage() const
Convert 'this' into a Image pointer if Object is a Image, otherwise return 0.
Definition Image:195
static unsigned int computeBlockSize(GLenum pixelFormat, GLenum packing)
return the size in bytes of a block of compressed pixels
virtual ~Image()
void setPixelAspectRatio(float pixelAspectRatio)
Set the pixel aspect ratio, defined as the pixel width divided by the pixel height.
Definition Image:318
unsigned int getRowStepInBytes() const
Return the number of bytes between each successive row.
Definition Image:331
virtual bool isImageTranslucent() const
Return true if this image is translucent - i.e.
int _s
Definition Image:564
Origin _origin
Definition Image:562
float _pixelAspectRatio
Definition Image:570
static unsigned int computePixelSizeInBits(GLenum pixelFormat, GLenum type)
WriteHint getWriteHint() const
Definition Image:213
const unsigned char * getMipmapData(unsigned int mipmapLevel) const
Definition Image:487
virtual bool sendPointerEvent(int, int, int)
Send pointer events to images that are acting as front ends to interactive surfaces such as a vnc or ...
Definition Image:526
void setColor(const osg::Vec4 &color, const osg::Vec2 &texcoord)
Set the color value for specified texcoord.
Definition Image:420
void setColor(const osg::Vec4 &color, const osg::Vec3 &texcoord)
Set the color value for specified texcoord.
virtual osg::Image * asImage()
Convert 'this' into a Image pointer if Object is a Image, otherwise return 0.
Definition Image:194
const std::string & getFileName() const
Definition Image:204
void setPixelFormat(GLenum pixelFormat)
void flipDepth()
Flip the image around the r dimension.
void flipVertical()
Flip the image vertically, around t dimension.
const MipmapDataType & getMipmapLevels() const
Definition Image:471
virtual void setFrameLastRendered(const osg::FrameStamp *)
Pass frame information to the custom Image classes, to be called only when objects associated with im...
Definition Image:532
virtual const char * className() const
return the name of the object's class type.
Definition Image:192
bool supportsTextureSubloading() const
returns false for texture formats that do not support texture subloading
virtual void setImage(int s, int t, int r, GLint internalTextureformat, GLenum pixelFormat, GLenum type, unsigned char *data, AllocationMode mode, int packing=1, int rowLength=0)
Set the image dimensions, format and data.
const unsigned char * data(unsigned int column, unsigned int row=0, unsigned int image=0) const
Definition Image:365
std::string _fileName
Definition Image:559
virtual int compare(const Image &rhs) const
Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
void setAllocationMode(AllocationMode mode)
Set the method used for deleting data once it goes out of scope.
Definition Image:222
unsigned int getImageSizeInBytes() const
Return the number of bytes each image (_s*_t) of pixels occupies.
Definition Image:334
static unsigned int computeRowWidthInBytes(int width, GLenum pixelFormat, GLenum type, int packing)
void setWriteHint(WriteHint writeHint)
Definition Image:212
GLint getInternalTextureFormat() const
Definition Image:303
static int computeNearestPowerOfTwo(int s, float bias=0.5f)
int r() const
Depth of image.
Definition Image:297
void setFileName(const std::string &fileName)
std::vector< unsigned int > MipmapDataType
Precomputed mipmaps stuff.
Definition Image:459
GLenum _dataType
Definition Image:568
unsigned char * data()
Raw image data.
Definition Image:352
void scaleImage(int s, int t, int r)
Scale image to specified size.
Definition Image:258
GLint _internalTextureFormat
Definition Image:566
bool isMipmap() const
Definition Image:461
virtual bool requiresUpdateCall() const
Return whether the update(NodeVisitor* nv) should be required on each frame to enable proper working ...
Definition Image:508
int getRowLength() const
Definition Image:300
static int roudUpToMultiple(int s, int pack)
void addDimensionsChangedCallback(DimensionsChangedCallback *cb)
GLenum _pixelFormat
Definition Image:567
void swap(osg::Image &rhs)
swap the data and settings between two image objects.
GLenum getPixelFormat() const
Definition Image:306
static osg::Vec3i computeBlockFootprint(GLenum pixelFormat)
return the dimensions of a block of compressed pixels
virtual void allocateImage(int s, int t, int r, GLenum pixelFormat, GLenum type, int packing=1)
Allocate a pixel block of specified size and type.
const unsigned char * data() const
Raw const image data.
Definition Image:357
std::vector< osg::ref_ptr< DimensionsChangedCallback > > DimensionsChangedCallbackVector
Definition Image:540
Vec4 getColor(const Vec3 &texcoord) const
Get the color value for specified texcoord.
WriteHint _writeHint
Definition Image:560
AllocationMode _allocationMode
Definition Image:572
bool isDataContiguous() const
return true if the data stored in the image is a contiguous block of data.
Definition Image:372
unsigned int getPixelSizeInBits() const
Return the number of bits required for each pixel.
Definition Image:324
const unsigned char * data() const
data pointer of current block to copy.
Definition Image:389
int _rowNum
Definition Image:400
int _imageNum
Definition Image:401
unsigned int _currentSize
Definition Image:404
DataIterator(const Image *image)
const osg::Image * _image
Definition Image:399
~DataIterator()
Definition Image:380
bool valid() const
is iterator valid.
Definition Image:386
DataIterator(const DataIterator &ri)
const unsigned char * _currentPtr
Definition Image:403
unsigned int size() const
Size of current block to copy.
Definition Image:392
unsigned int _mipmapNum
Definition Image:402
Convenience update callback class that can be attached to a StateAttribute (such as Textures) to ensu...
Definition Image:518
DimensionsChangedCallback()
Definition Image:536
virtual void operator()(osg::Image *image)=0
Visitor for type safe operations on osg::Nodes.
Definition NodeVisitor:82
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
Base class for providing reference counted objects.
Definition Referenced:44
Base class for state attributes.
Definition StateAttribute:77
value_type & x()
Definition Vec2f:67
value_type & y()
Definition Vec2f:68
General purpose integer triple.
Definition Vec3i:22
#define NULL
Definition Export:55
#define OSG_EXPORT
Definition Export:39

osg logo
Generated at Wed Jul 23 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.