Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

OgreImage.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2005 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef _Image_H__
00026 #define _Image_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 #include "OgreCommon.h"
00030 #include "OgrePixelFormat.h"
00031 #include "OgreDataStream.h"
00032 
00033 namespace Ogre {
00034 
00035     enum ImageFlags
00036     {
00037         IF_COMPRESSED = 0x00000001,
00038         IF_CUBEMAP    = 0x00000002,
00039         IF_3D_TEXTURE = 0x00000004
00040     };
00052     class _OgreExport Image
00053     {
00054     public:
00055         typedef Ogre::Box Box;
00056         typedef Ogre::Rect Rect;
00057     public:
00060         Image();
00063         Image( const Image &img );
00064 
00067         virtual ~Image();
00068 
00071         Image & operator = ( const Image & img );
00072 
00092         Image & flipAroundY();
00093 
00108         Image & flipAroundX();
00109 
00139         Image& loadDynamicImage( uchar* pData, size_t uWidth, size_t uHeight, 
00140                             size_t depth,
00141                              PixelFormat eFormat, bool autoDelete = false, 
00142                              size_t numFaces = 1, size_t numMipMaps = 0);
00143         
00165         Image& loadDynamicImage( uchar* pData, size_t uWidth,
00166                                  size_t uHeight, PixelFormat eFormat)
00167         {
00168             return loadDynamicImage(pData, uWidth, uHeight, 1, eFormat);
00169         }
00175         Image & loadRawData( 
00176             DataStreamPtr& stream, 
00177             size_t uWidth, size_t uHeight, size_t uDepth,
00178             PixelFormat eFormat,
00179             size_t numFaces = 1, size_t numMipMaps = 0);
00185         Image & loadRawData( 
00186             DataStreamPtr& stream, 
00187             size_t uWidth, size_t uHeight, 
00188             PixelFormat eFormat )
00189         {
00190             return loadRawData(stream, uWidth, uHeight, 1, eFormat);
00191         }
00192 
00207         Image & load( const String& strFileName, const String& groupName );
00208 
00223         Image & load(DataStreamPtr& stream, const String& type );
00224         
00226         void save(const String& filename);
00227 
00230         uchar* getData(void);
00231 
00234         const uchar * getData() const;       
00235 
00238         size_t getSize() const;
00239 
00242         size_t getNumMipmaps() const;
00243 
00246         bool hasFlag(const ImageFlags imgFlag) const;
00247 
00250         size_t getWidth(void) const;
00251 
00254         size_t getHeight(void) const;
00255 
00258         size_t getDepth(void) const;
00259         
00263         size_t getNumFaces(void) const;
00264 
00267         size_t getRowSpan(void) const;
00268 
00271         PixelFormat getFormat() const;
00272 
00275         uchar getBPP() const;
00276 
00279         bool getHasAlpha() const;
00280         
00286         static void applyGamma( uchar *buffer, Real gamma, size_t size, uchar bpp );
00287 
00293         ColourValue getColourAt(int x, int y, int z);
00294         
00298         PixelBox getPixelBox(size_t face = 0, size_t mipmap = 0) const;
00299 
00300         enum Filter
00301         {
00302             FILTER_NEAREST,
00303             FILTER_LINEAR,
00304             FILTER_BILINEAR,
00305             FILTER_BOX,
00306             FILTER_TRIANGLE,
00307             FILTER_BICUBIC
00308         };
00316         static void scale(const PixelBox &src, const PixelBox &dst, Filter filter = FILTER_BILINEAR);
00317         
00319         void resize(ushort width, ushort height, Filter filter = FILTER_BILINEAR);
00320         
00321         // Static function to calculate size in bytes from the number of mipmaps, faces and the dimensions
00322         static size_t calculateSize(size_t mipmaps, size_t faces, size_t width, size_t height, size_t depth, PixelFormat format);
00323     private:
00324         // The width of the image in pixels
00325         size_t m_uWidth;
00326         // The height of the image in pixels
00327         size_t m_uHeight;
00328         // The depth of the image
00329         size_t m_uDepth;
00330         // The size of the image buffer
00331         size_t m_uSize;
00332         // The number of mipmaps the image contains
00333         size_t m_uNumMipmaps;
00334         // Image specific flags.
00335         int m_uFlags;
00336 
00337         // The pixel format of the image
00338         PixelFormat m_eFormat;
00339 
00340         // The number of bytes per pixel
00341         uchar m_ucPixelSize;
00342         uchar* m_pBuffer;
00343 
00344         // A bool to determine if we delete the buffer or the calling app does
00345         bool m_bAutoDelete;
00346     };
00347 
00348 } // namespace
00349 
00350 #endif

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:42 2006