OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreImage.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef _Image_H__
29 #define _Image_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreCommon.h"
33 #include "OgrePixelFormat.h"
34 
35 namespace Ogre {
44  {
45  IF_COMPRESSED = 0x00000001,
46  IF_CUBEMAP = 0x00000002,
47  IF_3D_TEXTURE = 0x00000004
48  };
60  class _OgreExport Image : public ImageAlloc
61  {
62  public:
63  typedef Ogre::Box Box;
64  typedef Ogre::Rect Rect;
65  public:
68  Image();
71  Image( const Image &img );
72 
75  virtual ~Image();
76 
79  Image & operator = ( const Image & img );
80 
100  Image & flipAroundY();
101 
116  Image & flipAroundX();
117 
164  Image& loadDynamicImage( uchar* data, uint32 width, uint32 height,
165  uint32 depth,
166  PixelFormat format, bool autoDelete = false,
167  size_t numFaces = 1, uint8 numMipMaps = 0);
168 
205  uint32 height, PixelFormat format)
206  {
207  return loadDynamicImage(data, width, height, 1, format);
208  }
228  Image & loadRawData(
229  DataStreamPtr& stream,
230  uint32 width, uint32 height, uint32 depth,
231  PixelFormat format,
232  size_t numFaces = 1, size_t numMipMaps = 0);
253  DataStreamPtr& stream,
254  uint32 width, uint32 height,
255  PixelFormat format )
256  {
257  return loadRawData(stream, width, height, 1, format);
258  }
259 
275  Image & load( const String& filename, const String& groupName );
276 
297  Image & load(DataStreamPtr& stream, const String& type = BLANKSTRING );
298 
309  Image & loadTwoImagesAsRGBA(const String& rgbFilename, const String& alphaFilename,
310  const String& groupName, PixelFormat format = PF_BYTE_RGBA);
311 
327  Image & loadTwoImagesAsRGBA(DataStreamPtr& rgbStream, DataStreamPtr& alphaStream, PixelFormat format = PF_BYTE_RGBA,
328  const String& rgbType = BLANKSTRING, const String& alphaType = BLANKSTRING);
329 
339  Image & combineTwoImagesAsRGBA(const Image& rgb, const Image& alpha, PixelFormat format = PF_BYTE_RGBA);
340 
341 
351  void save(const String& filename);
352 
357  DataStreamPtr encode(const String& formatextension);
358 
365  uchar* getData(void);
366 
373  const uchar * getData() const;
374 
377  size_t getSize() const;
378 
381  uint8 getNumMipmaps() const;
382 
385  bool hasFlag(const ImageFlags imgFlag) const;
386 
389  uint32 getWidth(void) const;
390 
393  uint32 getHeight(void) const;
394 
397  uint32 getDepth(void) const;
398 
402  size_t getNumFaces(void) const;
403 
406  size_t getRowSpan(void) const;
407 
410  PixelFormat getFormat() const;
411 
414  uchar getBPP() const;
415 
418  bool getHasAlpha() const;
419 
425  static void applyGamma( uchar *buffer, Real gamma, size_t size, uchar bpp );
426 
432  ColourValue getColourAt(size_t x, size_t y, size_t z) const;
433 
439  void setColourAt(ColourValue const &cv, size_t x, size_t y, size_t z);
440 
444  PixelBox getPixelBox(size_t face = 0, size_t mipmap = 0) const;
445 
447  void freeMemory();
448 
449  enum Filter
450  {
456  FILTER_BICUBIC
457  };
465  static void scale(const PixelBox &src, const PixelBox &dst, Filter filter = FILTER_BILINEAR);
466 
468  void resize(ushort width, ushort height, Filter filter = FILTER_BILINEAR);
469 
471  static size_t calculateSize(size_t mipmaps, size_t faces, uint32 width, uint32 height, uint32 depth, PixelFormat format);
472 
474  static String getFileExtFromMagic(DataStreamPtr stream);
475 
476  protected:
484  size_t mBufSize;
488  int mFlags;
489 
492 
496 
499  };
500 
503 
507 } // namespace
508 
509 #endif
unsigned char uint8
Definition: OgrePlatform.h:422
float Real
Software floating point type.
unsigned int uint32
Definition: OgrePlatform.h:420
#define _OgreExport
Definition: OgrePlatform.h:255
ImageFlags
Definition: OgreImage.h:43
std::vector< T, A > type
Class representing colour.
vector< const Image * >::type ConstImagePtrList
Definition: OgreImage.h:502
const String BLANKSTRING
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreCommon.h:574
vector< Image * >::type ImagePtrList
Definition: OgreImage.h:501
Image & loadDynamicImage(uchar *data, uint32 width, uint32 height, PixelFormat format)
Stores a pointer to raw data in memory.
Definition: OgreImage.h:204
uchar * mBuffer
Definition: OgreImage.h:495
uint8 mNumMipmaps
The number of mipmaps the image contains.
Definition: OgreImage.h:486
4 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue, and one byte for alpha ...
Structure used to define a box in a 3-D integer space.
Definition: OgreCommon.h:689
PixelFormat
The pixel format used for images, textures, and render surfaces.
unsigned char uchar
In order to avoid finger-aches :)
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Image & loadRawData(DataStreamPtr &stream, uint32 width, uint32 height, PixelFormat format)
Loads raw data from a stream.
Definition: OgreImage.h:252
Class representing an image file.
Definition: OgreImage.h:60
unsigned short ushort
int mFlags
Image specific flags.
Definition: OgreImage.h:488
size_t mBufSize
The size of the image buffer.
Definition: OgreImage.h:484
bool mAutoDelete
A bool to determine if we delete the buffer or the calling app does.
Definition: OgreImage.h:498
uint32 mWidth
The width of the image in pixels.
Definition: OgreImage.h:478
_StringBase String
Definition: OgreCommon.h:53
PixelFormat mFormat
The pixel format of the image.
Definition: OgreImage.h:491
Ogre::Rect Rect
Definition: OgreImage.h:64
Ogre::Box Box
Definition: OgreImage.h:63
uint32 mHeight
The height of the image in pixels.
Definition: OgreImage.h:480
uint32 mDepth
The depth of the image.
Definition: OgreImage.h:482
uchar mPixelSize
The number of bytes per pixel.
Definition: OgreImage.h:494