00001 //////////////////////////////////////////////////////////////////////
00002 // Copyright (c) 2001-2002 David Pritchard <drpritch@alumni.uwaterloo.ca>
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License
00006 // as published by the Free Software Foundation; either
00007 // version 2 of the License, or (at your option) any later
00008 // version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013 // GNU Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018
00019 #ifndef freecloth_gfx_gfxImage_inline_h
00020 #define freecloth_gfx_gfxImage_inline_h
00021
00022 ////////////////////////////////////////////////////////////////////////////////
00023 // CLASS GfxImage
00024
00025 //------------------------------------------------------------------------------
00026
00027 inline UInt32 GfxImage::getWidth() const
00028 {
00029 return _width;
00030 }
00031
00032 //------------------------------------------------------------------------------
00033
00034 inline UInt32 GfxImage::getHeight() const
00035 {
00036 return _height;
00037 }
00038
00039 //------------------------------------------------------------------------------
00040
00041 inline Float GfxImage::getAspectRatio() const
00042 {
00043 return static_cast<Float>( _width ) / _height;
00044 }
00045
00046 //------------------------------------------------------------------------------
00047
00048 inline UInt8* GfxImage::getRawData()
00049 {
00050 return &_dataPtr->front();
00051 }
00052
00053 //------------------------------------------------------------------------------
00054
00055 inline const UInt8* GfxImage::getRawData() const
00056 {
00057 return &_dataPtr->front();
00058 }
00059
00060 //------------------------------------------------------------------------------
00061
00062 inline UInt8 GfxImage::getData( UInt32 x, UInt32 y, UInt32 component ) const
00063 {
00064 DGFX_ASSERT( getBitsPerComponent() == 8 );
00065 DGFX_ASSERT(
00066 x < getWidth() && y < getHeight() && component < getNbComponents()
00067 );
00068 return (*_dataPtr)[
00069 y * getBytesPerRow() + x * getBytesPerPixel() + component
00070 ];
00071 }
00072
00073 //------------------------------------------------------------------------------
00074
00075 inline UInt8& GfxImage::getData( UInt32 x, UInt32 y, UInt32 component )
00076 {
00077 DGFX_ASSERT( getBitsPerComponent() == 8 );
00078 DGFX_ASSERT(
00079 x < getWidth() && y < getHeight() && component < getNbComponents()
00080 );
00081 return (*_dataPtr)[
00082 y * getBytesPerRow() + x * getBytesPerPixel() + component
00083 ];
00084 }
00085
00086 //------------------------------------------------------------------------------
00087
00088 inline UInt32 GfxImage::getRawSize() const
00089 {
00090 return getBytesPerRow() * getHeight();
00091 }
00092
00093 #endif
1.2.14 written by Dimitri van Heesch,
© 1997-2002