OGRE: OgreImage.h Source File - OGRE Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | 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-2006 Torus Knot Software Ltd
    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 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029 #ifndef _Image_H__
    00030 #define _Image_H__
    00031
    00032 #include "OgrePrerequisites.h"
    00033 #include "OgreCommon.h"
    00034 #include "OgrePixelFormat.h"
    00035 #include "OgreDataStream.h"
    00036
    00037 namespace Ogre {
    00038
    00039     enum ImageFlags
    00040     {
    00041         IF_COMPRESSED = 0x00000001,
    00042         IF_CUBEMAP    = 0x00000002,
    00043         IF_3D_TEXTURE = 0x00000004
    00044     };
    00056     class _OgreExport Image
    00057     {
    00058     public:
    00059         typedef Ogre::Box Box;
    00060         typedef Ogre::Rect Rect;
    00061     public:
    00064         Image();
    00067         Image( const Image &img );
    00068
    00071         virtual ~Image();
    00072
    00075         Image & operator = ( const Image & img );
    00076
    00096         Image & flipAroundY();
    00097
    00112         Image & flipAroundX();
    00113
    00157         Image& loadDynamicImage( uchar* pData, size_t uWidth, size_t uHeight,
    00158                             size_t depth,
    00159                              PixelFormat eFormat, bool autoDelete = false,
    00160                              size_t numFaces = 1, size_t numMipMaps = 0);
    00161
    00197         Image& loadDynamicImage( uchar* pData, size_t uWidth,
    00198                                  size_t uHeight, PixelFormat eFormat)
    00199         {
    00200             return loadDynamicImage(pData, uWidth, uHeight, 1, eFormat);
    00201         }
    00221         Image & loadRawData(
    00222             DataStreamPtr& stream,
    00223             size_t uWidth, size_t uHeight, size_t uDepth,
    00224             PixelFormat eFormat,
    00225             size_t numFaces = 1, size_t numMipMaps = 0);
    00245         Image & loadRawData(
    00246             DataStreamPtr& stream,
    00247             size_t uWidth, size_t uHeight,
    00248             PixelFormat eFormat )
    00249         {
    00250             return loadRawData(stream, uWidth, uHeight, 1, eFormat);
    00251         }
    00252
    00268         Image & load( const String& strFileName, const String& groupName );
    00269
    00289         Image & load(DataStreamPtr& stream, const String& type );
    00290
    00292         void save(const String& filename);
    00293
    00300         uchar* getData(void);
    00301
    00308         const uchar * getData() const;
    00309
    00312         size_t getSize() const;
    00313
    00316         size_t getNumMipmaps() const;
    00317
    00320         bool hasFlag(const ImageFlags imgFlag) const;
    00321
    00324         size_t getWidth(void) const;
    00325
    00328         size_t getHeight(void) const;
    00329
    00332         size_t getDepth(void) const;
    00333
    00337         size_t getNumFaces(void) const;
    00338
    00341         size_t getRowSpan(void) const;
    00342
    00345         PixelFormat getFormat() const;
    00346
    00349         uchar getBPP() const;
    00350
    00353         bool getHasAlpha() const;
    00354
    00360         static void applyGamma( uchar *buffer, Real gamma, size_t size, uchar bpp );
    00361
    00367         ColourValue getColourAt(int x, int y, int z);
    00368
    00372         PixelBox getPixelBox(size_t face = 0, size_t mipmap = 0) const;
    00373
    00374         enum Filter
    00375         {
    00376             FILTER_NEAREST,
    00377             FILTER_LINEAR,
    00378             FILTER_BILINEAR,
    00379             FILTER_BOX,
    00380             FILTER_TRIANGLE,
    00381             FILTER_BICUBIC
    00382         };
    00390         static void scale(const PixelBox &src, const PixelBox &dst, Filter filter = FILTER_BILINEAR);
    00391
    00393         void resize(ushort width, ushort height, Filter filter = FILTER_BILINEAR);
    00394
    00395         // Static function to calculate size in bytes from the number of mipmaps, faces and the dimensions
    00396         static size_t calculateSize(size_t mipmaps, size_t faces, size_t width, size_t height, size_t depth, PixelFormat format);
    00397     private:
    00398         // The width of the image in pixels
    00399         size_t m_uWidth;
    00400         // The height of the image in pixels
    00401         size_t m_uHeight;
    00402         // The depth of the image
    00403         size_t m_uDepth;
    00404         // The size of the image buffer
    00405         size_t m_uSize;
    00406         // The number of mipmaps the image contains
    00407         size_t m_uNumMipmaps;
    00408         // Image specific flags.
    00409         int m_uFlags;
    00410
    00411         // The pixel format of the image
    00412         PixelFormat m_eFormat;
    00413
    00414         // The number of bytes per pixel
    00415         uchar m_ucPixelSize;
    00416         uchar* m_pBuffer;
    00417
    00418         // A bool to determine if we delete the buffer or the calling app does
    00419         bool m_bAutoDelete;
    00420     };
    00421
    00422     typedef std::vector<Image*> ImagePtrList;
    00423     typedef std::vector<const Image*> ConstImagePtrList;
    00424
    00425
    00426 } // namespace
    00427
    00428 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Thu Mar 6 09:46:25 2008