1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
7 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
35 \*---------------------------------------------------------------------------*/
37 //---------------------------------------------------------------------------
39 //---------------------------------------------------------------------------
44 /*! Check if the pixelFormat, dimension, bpp and data are valid (not null)
49 bool Image::isValid(void) const
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
60 SizeT Image::getHash(bool force) const
62 if(force || !_hashValid)
68 /*! returns the data size in bytes.
71 unsigned long Image::getSize(bool withMipmap,
73 bool withSides ) const
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
84 const UInt8 *Image::getData(UInt32 mipmapNum,
86 UInt32 sideNum ) const
93 (sideNum * getSideSize ()) +
94 (frameNum * getFrameSize());
98 data += calcMipmapSumSize(mipmapNum);
105 UInt8 *Image::editData(UInt32 mipmapNum,
112 editMField(PixelFieldMask, _mfPixel);
116 (sideNum * getSideSize ()) +
117 (frameNum * getFrameSize());
121 data += calcMipmapSumSize(mipmapNum);
128 /*! returns a data pointer for a single frame/mipmap chunk
132 const UInt8 *Image::getDataFast(UInt32 mipmapNum,
138 (sideNum * getSideSize ()) +
139 (frameNum * getFrameSize());
141 if(_mipmapOffset.size() <= mipmapNum)
144 data += _mipmapOffset[mipmapNum];
150 UInt8 *Image::editDataFast(UInt32 mipmapNum,
154 editMField(PixelFieldMask, _mfPixel);
158 (sideNum * getSideSize ()) +
159 (frameNum * getFrameSize());
161 if(_mipmapOffset.size() <= mipmapNum)
164 data += _mipmapOffset[mipmapNum];
171 // Specialization for Image we need this to support VRML PixelTextures.
173 void SFImagePtr::pushValueByStr(const Char8 *str)
175 if(getValue() != NullFC)
176 getValue()->addValue(str);