OgreImage.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef _Image_H__
#define _Image_H__
#include "OgrePrerequisites.h"
#include "OgreCommon.h"
#include "OgrePixelFormat.h"
#include "OgreDataStream.h"
namespace Ogre {
enum ImageFlags
{
IF_COMPRESSED = 0x00000001,
IF_CUBEMAP = 0x00000002,
IF_3D_TEXTURE = 0x00000004
};
class _OgreExport Image : public ImageAlloc
{
public:
typedef Ogre::Box Box;
typedef Ogre::Rect Rect;
public:
Image();
Image( const Image &img );
virtual ~Image();
Image & operator = ( const Image & img );
Image & flipAroundY();
Image & flipAroundX();
Image& loadDynamicImage( uchar* data, uint32 width, uint32 height,
uint32 depth,
PixelFormat format, bool autoDelete = false,
size_t numFaces = 1, uint8 numMipMaps = 0);
Image& loadDynamicImage( uchar* data, uint32 width,
uint32 height, PixelFormat format)
{
return loadDynamicImage(data, width, height, 1, format);
}
Image & loadRawData(
DataStreamPtr& stream,
uint32 width, uint32 height, uint32 depth,
PixelFormat format,
size_t numFaces = 1, size_t numMipMaps = 0);
Image & loadRawData(
DataStreamPtr& stream,
uint32 width, uint32 height,
PixelFormat format )
{
return loadRawData(stream, width, height, 1, format);
}
Image & load( const String& filename, const String& groupName );
Image & load(DataStreamPtr& stream, const String& type = StringUtil::BLANK );
Image & loadTwoImagesAsRGBA(const String& rgbFilename, const String& alphaFilename,
const String& groupName, PixelFormat format = PF_BYTE_RGBA);
Image & loadTwoImagesAsRGBA(DataStreamPtr& rgbStream, DataStreamPtr& alphaStream, PixelFormat format = PF_BYTE_RGBA,
const String& rgbType = StringUtil::BLANK, const String& alphaType = StringUtil::BLANK);
Image & combineTwoImagesAsRGBA(const Image& rgb, const Image& alpha, PixelFormat format = PF_BYTE_RGBA);
void save(const String& filename);
DataStreamPtr encode(const String& formatextension);
uchar* getData(void);
const uchar * getData() const;
size_t getSize() const;
uint8 getNumMipmaps() const;
bool hasFlag(const ImageFlags imgFlag) const;
uint32 getWidth(void) const;
uint32 getHeight(void) const;
uint32 getDepth(void) const;
size_t getNumFaces(void) const;
size_t getRowSpan(void) const;
PixelFormat getFormat() const;
uchar getBPP() const;
bool getHasAlpha() const;
static void applyGamma( uchar *buffer, Real gamma, size_t size, uchar bpp );
ColourValue getColourAt(size_t x, size_t y, size_t z) const;
void setColourAt(ColourValue const &cv, size_t x, size_t y, size_t z);
PixelBox getPixelBox(size_t face = 0, size_t mipmap = 0) const;
void freeMemory();
enum Filter
{
FILTER_NEAREST,
FILTER_LINEAR,
FILTER_BILINEAR,
FILTER_BOX,
FILTER_TRIANGLE,
FILTER_BICUBIC
};
static void scale(const PixelBox &src, const PixelBox &dst, Filter filter = FILTER_BILINEAR);
void resize(ushort width, ushort height, Filter filter = FILTER_BILINEAR);
static size_t calculateSize(size_t mipmaps, size_t faces, uint32 width, uint32 height, uint32 depth, PixelFormat format);
static String getFileExtFromMagic(DataStreamPtr stream);
protected:
uint32 mWidth;
uint32 mHeight;
uint32 mDepth;
size_t mBufSize;
uint8 mNumMipmaps;
int mFlags;
PixelFormat mFormat;
uchar mPixelSize;
uchar* mBuffer;
bool mAutoDelete;
};
typedef vector<Image*>::type ImagePtrList;
typedef vector<const Image*>::type ConstImagePtrList;
} // namespace
#endif
Ogre::PF_BYTE_RGBA
4 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue, and one byte for alpha ...
Definition: OgrePixelFormat.h:105
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::vector::type
std::vector< T, A > type
Definition: OgrePrerequisites.h:494
OgrePixelFormat.h
Ogre::Image::mAutoDelete
bool mAutoDelete
A bool to determine if we delete the buffer or the calling app does.
Definition: OgreImage.h:499
Ogre::Image::loadRawData
Image & loadRawData(DataStreamPtr &stream, uint32 width, uint32 height, PixelFormat format)
Loads raw data from a stream.
Definition: OgreImage.h:253
Ogre::Image::mBufSize
size_t mBufSize
The size of the image buffer.
Definition: OgreImage.h:485
Ogre::ColourValue
Class representing colour.
Definition: OgreColourValue.h:57
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::Image::FILTER_TRIANGLE
Definition: OgreImage.h:456
Ogre::IF_3D_TEXTURE
Definition: OgreImage.h:48
Ogre::TRect< long >
Ogre::uchar
unsigned char uchar
In order to avoid finger-aches :)
Definition: OgrePrerequisites.h:112
Ogre::PixelFormat
PixelFormat
The pixel format used for images, textures, and render surfaces.
Definition: OgrePixelFormat.h:43
Ogre::Image::FILTER_NEAREST
Definition: OgreImage.h:452
OgreDataStream.h
Ogre::Image::mWidth
uint32 mWidth
The width of the image in pixels.
Definition: OgreImage.h:479
Ogre::Box
Structure used to define a box in a 3-D integer space.
Definition: OgreCommon.h:659
OgreCommon.h
Ogre::Image::mDepth
uint32 mDepth
The depth of the image.
Definition: OgreImage.h:483
Ogre::Image::mNumMipmaps
uint8 mNumMipmaps
The number of mipmaps the image contains.
Definition: OgreImage.h:487
Ogre::Image::FILTER_BILINEAR
Definition: OgreImage.h:454
Ogre::Image::mPixelSize
uchar mPixelSize
The number of bytes per pixel.
Definition: OgreImage.h:495
Ogre::Image::Filter
Filter
Definition: OgreImage.h:450
Ogre::ImageFlags
ImageFlags
Definition: OgreImage.h:44
OgrePrerequisites.h
Ogre::Image::mFlags
int mFlags
Image specific flags.
Definition: OgreImage.h:489
Ogre::uint8
unsigned char uint8
Definition: OgrePlatform.h:361
Ogre::Image::FILTER_BOX
Definition: OgreImage.h:455
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::Image::FILTER_LINEAR
Definition: OgreImage.h:453
Ogre::Image::mBuffer
uchar * mBuffer
Definition: OgreImage.h:496
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre::Image
Class representing an image file.
Definition: OgreImage.h:61
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::Image::mFormat
PixelFormat mFormat
The pixel format of the image.
Definition: OgreImage.h:492
Ogre::SharedPtr< DataStream >
Ogre::IF_COMPRESSED
Definition: OgreImage.h:46
Ogre::ConstImagePtrList
vector< const Image * >::type ConstImagePtrList
Definition: OgreImage.h:503
Ogre::Image::Box
Ogre::Box Box
Definition: OgreImage.h:64
Ogre::PixelBox
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
Definition: OgrePixelFormat.h:304
Ogre::ushort
unsigned short ushort
Definition: OgrePrerequisites.h:113
Ogre::ImagePtrList
vector< Image * >::type ImagePtrList
Definition: OgreImage.h:502
Ogre::Image::Rect
Ogre::Rect Rect
Definition: OgreImage.h:65
Ogre::IF_CUBEMAP
Definition: OgreImage.h:47
Ogre::StringUtil::BLANK
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:58
Ogre::Image::loadDynamicImage
Image & loadDynamicImage(uchar *data, uint32 width, uint32 height, PixelFormat format)
Stores a pointer to raw data in memory.
Definition: OgreImage.h:205
Ogre::Image::mHeight
uint32 mHeight
The height of the image in pixels.
Definition: OgreImage.h:481

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.