fixed: gcc8 compile issues
[opensg.git] / Source / System / Image / OSGImage.inl
blob90364baf1e20645bffa78f1e7c92b534cd2e8334
1 /*---------------------------------------------------------------------------*\
2  *                                OpenSG                                     *
3  *                                                                           *
4  *                                                                           *
5  *               Copyright (C) 2000-2002 by the OpenSG Forum                 *
6  *                                                                           *
7  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
8  *                                                                           *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
11  *                                License                                    *
12  *                                                                           *
13  * This library is free software; you can redistribute it and/or modify it   *
14  * under the terms of the GNU Library General Public License as published    *
15  * by the Free Software Foundation, version 2.                               *
16  *                                                                           *
17  * This library is distributed in the hope that it will be useful, but       *
18  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
20  * Library General Public License for more details.                          *
21  *                                                                           *
22  * You should have received a copy of the GNU Library General Public         *
23  * License along with this library; if not, write to the Free Software       *
24  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
25  *                                                                           *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
28  *                                Changes                                    *
29  *                                                                           *
30  *                                                                           *
31  *                                                                           *
32  *                                                                           *
33  *                                                                           *
34  *                                                                           *
35 \*---------------------------------------------------------------------------*/
37 //---------------------------------------------------------------------------
38 //  Includes
39 //---------------------------------------------------------------------------
41 OSG_BEGIN_NAMESPACE
44 /*! Check if the pixelFormat, dimension, bpp and data are valid (not null)
45     with a single call.    
46  */
48 inline 
49 bool Image::isValid(void) const
50
51     return !_mfPixel.empty();
54 /*! Returns a hash value calculated over the image's pixel data. The hash value
55     is cached and only (re-)calculated if the cached value has been invalidated
56     or \a force is true.
59 inline
60 SizeT Image::getHash(bool force) const
62     if(force || !_hashValid)
63         calcHash();
65     return _hash;
68 /*! returns the data size in bytes. 
69  */
70 inline 
71 unsigned long Image::getSize(bool withMipmap,
72                              bool withFrames,
73                              bool withSides ) const
74
75     return ( (calcMipmapSumSize((withMipmap ? getMipMapCount() : 1))) *
76              (withSides  ? getSideCount () : 1                      ) *
77              (withFrames ? getFrameCount() : 1                      ) ); 
80 /*! returns a data pointer for a single frame/mipmap chunk
81  */
83 inline 
84 const UInt8 *Image::getData(UInt32 mipmapNum, 
85                             UInt32 frameNum,
86                             UInt32 sideNum ) const
88     if(_mfPixel.empty())
89         return NULL;
91     const UInt8 *data = 
92         (&(_mfPixel[0])           ) + 
93         (sideNum  * getSideSize ()) +
94         (frameNum * getFrameSize());
95     
96     if (mipmapNum)
97     {
98         data += calcMipmapSumSize(mipmapNum);
99     }
100   
101     return data;
104 inline 
105 UInt8 *Image::editData(UInt32 mipmapNum, 
106                        UInt32 frameNum,
107                        UInt32 sideNum) 
109     if(_mfPixel.empty())
110         return NULL;
112     editMField(PixelFieldMask, _mfPixel);
114     UInt8 *data = 
115         (&(_mfPixel[0])           ) + 
116         (sideNum  * getSideSize ()) +
117         (frameNum * getFrameSize());
118     
119     if (mipmapNum)
120     {
121         data += calcMipmapSumSize(mipmapNum);
122     }
124     return data;
128 /*! returns a data pointer for a single frame/mipmap chunk
129  */
131 inline 
132 const UInt8 *Image::getDataFast(UInt32 mipmapNum, 
133                                 UInt32 frameNum,
134                                 UInt32 sideNum ) 
136     const UInt8 *data = 
137         (&(_mfPixel[0])           ) + 
138         (sideNum  * getSideSize ()) +
139         (frameNum * getFrameSize());
140     
141     if(_mipmapOffset.size() <= mipmapNum)
142         calcMipmapOffsets();
144     data += _mipmapOffset[mipmapNum];
145    
146     return data;
149 inline 
150 UInt8 *Image::editDataFast(UInt32 mipmapNum, 
151                            UInt32 frameNum,
152                            UInt32 sideNum) 
154     editMField(PixelFieldMask, _mfPixel);
156     UInt8 *data = 
157         (&(_mfPixel[0])           ) + 
158         (sideNum  * getSideSize ()) +
159         (frameNum * getFrameSize());
160     
161     if(_mipmapOffset.size() <= mipmapNum)
162         calcMipmapOffsets();
164     data += _mipmapOffset[mipmapNum];
165   
166     return data;
170 #ifdef CHECK_GV
171 // Specialization for Image we need this to support VRML PixelTextures.
172 template <> inline
173 void SFImagePtr::pushValueByStr(const Char8 *str)
175     if(getValue() != NullFC)
176         getValue()->addValue(str);
178 #endif
180 OSG_END_NAMESPACE