00001 /*---------------------------------------------------------------------------*\ 00002 * OpenSG * 00003 * * 00004 * * 00005 * Copyright (C) 2000-2002 by the OpenSG Forum * 00006 * * 00007 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de * 00008 * * 00009 \*---------------------------------------------------------------------------*/ 00010 /*---------------------------------------------------------------------------*\ 00011 * License * 00012 * * 00013 * This library is free software; you can redistribute it and/or modify it * 00014 * under the terms of the GNU Library General Public License as published * 00015 * by the Free Software Foundation, version 2. * 00016 * * 00017 * This library is distributed in the hope that it will be useful, but * 00018 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00020 * Library General Public License for more details. * 00021 * * 00022 * You should have received a copy of the GNU Library General Public * 00023 * License along with this library; if not, write to the Free Software * 00024 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00025 * * 00026 \*---------------------------------------------------------------------------*/ 00027 /*---------------------------------------------------------------------------*\ 00028 * Changes * 00029 * * 00030 * * 00031 * * 00032 * * 00033 * * 00034 * * 00035 \*---------------------------------------------------------------------------*/ 00036 00037 //--------------------------------------------------------------------------- 00038 // Includes 00039 //--------------------------------------------------------------------------- 00040 00041 #include <OSGConfig.h> 00042 00043 OSG_BEGIN_NAMESPACE 00044 00045 inline bool Image::isValid (void) const 00046 { 00047 return !getPixel().empty(); 00048 } 00049 00052 inline unsigned long Image::getSize ( bool withMipmap, 00053 bool withFrames, 00054 bool withSides ) const 00055 { 00056 return ( calcMipmapSumSize((withMipmap ? getMipMapCount() : 1)) * 00057 (withSides ? getSideCount() : 1) * 00058 (withFrames ? getFrameCount() : 1) ); 00059 } 00060 00063 inline UInt8 *Image::getData( UInt32 mipmapNum, 00064 UInt32 frameNum, 00065 UInt32 sideNum ) 00066 { 00067 if(getPixel().empty()) 00068 return NULL; 00069 00070 UInt8 *data = (&getPixel()[0]) + 00071 (sideNum * getSideSize()) + 00072 (frameNum * getFrameSize()); 00073 00074 if (mipmapNum) 00075 { 00076 data += calcMipmapSumSize(mipmapNum); 00077 } 00078 00079 return data; 00080 } 00081 00084 inline const UInt8 *Image::getData( UInt32 mipmapNum, 00085 UInt32 frameNum, 00086 UInt32 sideNum ) const 00087 { 00088 if(getPixel().empty()) 00089 return NULL; 00090 00091 const UInt8 *data = (&getPixel()[0]) + 00092 (sideNum * getSideSize()) + 00093 (frameNum * getFrameSize()); 00094 00095 if (mipmapNum) 00096 { 00097 data += calcMipmapSumSize(mipmapNum); 00098 } 00099 00100 return data; 00101 } 00102 00103 // Specialization for Image we need this to support VRML PixelTextures. 00104 template <> inline 00105 void SFImagePtr::pushValueByStr(const Char8 *str) 00106 { 00107 if(getValue() != NullFC) 00108 getValue()->addValue(str); 00109 } 00110 00111 OSG_END_NAMESPACE 00112 00113 #define OSGIMAGE_INLINE_CVSID "@(#)$Id: $" 00114
1.5.5