OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgrePixelFormat.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 _PixelFormat_H__
29 #define _PixelFormat_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreCommon.h"
33 #include "OgreHeaderPrefix.h"
34 
35 namespace Ogre {
44  {
48  PF_L8 = 1,
51  PF_L16 = 2,
54  PF_A8 = 3,
57  PF_A4L4 = 4,
61  PF_R5G6B5 = 6,
63  PF_B5G6R5 = 7,
65  PF_R3G3B2 = 31,
71  PF_R8G8B8 = 10,
73  PF_B8G8R8 = 11,
88 #if OGRE_ENDIAN == OGRE_ENDIAN_BIG
97 #else
101  PF_BYTE_BGR = PF_R8G8B8,
103  PF_BYTE_BGRA = PF_A8R8G8B8,
105  PF_BYTE_RGBA = PF_A8B8G8R8,
106 #endif
107  PF_A2R10G10B10 = 15,
112  PF_DXT1 = 17,
114  PF_DXT2 = 18,
116  PF_DXT3 = 19,
118  PF_DXT4 = 20,
120  PF_DXT5 = 21,
127  // 32-bit pixel format, 32 bits (float) for red
138  PF_DEPTH = 29,
226  PF_R8 = 78,
228  PF_RG8 = 79,
259  // Number of pixel formats currently defined
260  PF_COUNT = 95
261  };
263 
269  PFF_HASALPHA = 0x00000001,
272  PFF_COMPRESSED = 0x00000002,
274  PFF_FLOAT = 0x00000004,
276  PFF_DEPTH = 0x00000008,
279  PFF_NATIVEENDIAN = 0x00000010,
282  PFF_LUMINANCE = 0x00000020,
284  PFF_INTEGER = 0x00000040
285  };
286 
289  {
290  PCT_BYTE = 0,
291  PCT_SHORT = 1,
294  PCT_SINT = 4,
295  PCT_UINT = 5,
297  };
298 
304  class _OgreExport PixelBox: public Box, public ImageAlloc {
305  public:
307  PixelBox() {}
316  PixelBox(const Box &extents, PixelFormat pixelFormat, void *pixelData=0):
317  Box(extents), data(pixelData), format(pixelFormat)
318  {
319  setConsecutive();
320  }
330  PixelBox(uint32 width, uint32 height, uint32 depth, PixelFormat pixelFormat, void *pixelData=0):
331  Box(0, 0, 0, width, height, depth),
332  data(pixelData), format(pixelFormat)
333  {
334  setConsecutive();
335  }
336 
338  void *data;
345  size_t rowPitch;
351  size_t slicePitch;
352 
357  {
358  rowPitch = getWidth();
359  slicePitch = getWidth()*getHeight();
360  }
365  size_t getRowSkip() const { return rowPitch - getWidth(); }
370  size_t getSliceSkip() const { return slicePitch - (getHeight() * rowPitch); }
371 
375  bool isConsecutive() const
376  {
377  return rowPitch == getWidth() && slicePitch == getWidth()*getHeight();
378  }
382  size_t getConsecutiveSize() const;
391  PixelBox getSubVolume(const Box &def) const;
392 
396  void* getTopLeftFrontPixelPtr() const;
397 
403  ColourValue getColourAt(size_t x, size_t y, size_t z);
404 
410  void setColourAt(ColourValue const &cv, size_t x, size_t y, size_t z);
411  };
412 
413 
418  public:
425  static size_t getNumElemBytes( PixelFormat format );
426 
433  static size_t getNumElemBits( PixelFormat format );
434 
452  static size_t getMemorySize(uint32 width, uint32 height, uint32 depth, PixelFormat format);
453 
461  static unsigned int getFlags( PixelFormat format );
462 
464  static bool hasAlpha(PixelFormat format);
466  static bool isFloatingPoint(PixelFormat format);
468  static bool isInteger(PixelFormat format);
470  static bool isCompressed(PixelFormat format);
472  static bool isDepth(PixelFormat format);
474  static bool isNativeEndian(PixelFormat format);
476  static bool isLuminance(PixelFormat format);
477 
490  static bool isValidExtent(size_t width, size_t height, size_t depth, PixelFormat format);
491 
495  static void getBitDepths(PixelFormat format, int rgba[4]);
496 
500  static void getBitMasks(PixelFormat format, uint64 rgba[4]);
501 
505  static void getBitShifts(PixelFormat format, unsigned char rgba[4]);
506 
509  static String getFormatName(PixelFormat srcformat);
510 
518  static bool isAccessible(PixelFormat srcformat);
519 
524  static PixelComponentType getComponentType(PixelFormat fmt);
525 
529  static size_t getComponentCount(PixelFormat fmt);
530 
538  static PixelFormat getFormatFromName(const String& name, bool accessibleOnly = false, bool caseSensitive = false);
539 
547  static String getBNFExpressionOfPixelFormats(bool accessibleOnly = false);
548 
558  static PixelFormat getFormatForBitDepths(PixelFormat fmt, ushort integerBits, ushort floatBits);
559 
565  static void packColour(const ColourValue &colour, const PixelFormat pf, void* dest);
573  static void packColour(const uint8 r, const uint8 g, const uint8 b, const uint8 a, const PixelFormat pf, void* dest);
581  static void packColour(const float r, const float g, const float b, const float a, const PixelFormat pf, void* dest);
582 
588  static void unpackColour(ColourValue *colour, PixelFormat pf, const void* src);
600  static void unpackColour(uint8 *r, uint8 *g, uint8 *b, uint8 *a, PixelFormat pf, const void* src);
609  static void unpackColour(float *r, float *g, float *b, float *a, PixelFormat pf, const void* src);
610 
619  static void bulkPixelConversion(void *src, PixelFormat srcFormat, void *dst, PixelFormat dstFormat, unsigned int count);
620 
628  static void bulkPixelConversion(const PixelBox &src, const PixelBox &dst);
629 
634  static void bulkPixelVerticalFlip(const PixelBox &box);
635  };
639 }
640 
641 #include "OgreHeaderSuffix.h"
642 
643 #endif
64-bit pixel format, 16 bits red (signed int), 16 bits blue (signed int), 16 bits green (signed int)...
unsigned char uint8
Definition: OgrePlatform.h:346
16-bit pixel format, 5 bits red, 6 bits green, 5 bits blue.
32-bit pixel format, 16-bit green, 16-bit red
32-bit pixel format, 32 bits red (signed int).
Short per component (16 bit fixed 0.0..1.0))
32-bit pixel format, 16 bits red (signed int), 16 bits blue (signed int).
8-bit pixel format, 8 bits red (unsigned int).
unsigned int uint32
Definition: OgrePlatform.h:344
8-bit pixel format, 8 bits red (signed int).
This is a depth format (for depth textures)
#define _OgreExport
Definition: OgrePlatform.h:260
8-bit pixel format, 4 bits alpha, 4 bits luminance.
PVRTC (PowerVR) Version 2, 4 bpp.
size_t rowPitch
Number of elements between the leftmost pixel of one row and the left pixel of the next...
DDS (DirectDraw Surface) BC4 format (unsigned normalised)
48-bit pixel format, 16 bits red (signed normalised int), 16 bits blue (signed normalised int)...
16-bit pixel format, 16 bits red (signed normalised int).
16-bit pixel format, 8 bits red (unsigned int), 8 bits blue (unsigned int).
48-bit pixel format, 16 bits red (signed int), 16 bits blue (signed int), 16 bits green (signed int)...
ATC (AMD_compressed_ATC_texture)
32 bit float per component
32-bit pixel format, 8 bits for alpha, red, green and blue.
48-bit pixel format, 16 bits red (unsigned int), 16 bits blue (unsigned int), 16 bits green (unsigned...
DDS (DirectDraw Surface) BC7 format (unsigned normalised sRGB)
ETC2 (Ericsson Texture Compression)
DDS (DirectDraw Surface) BC4 format (signed normalised)
16-bit pixel format, 8 bits red, 8 bits green.
Class representing colour.
DDS (DirectDraw Surface) DXT5 format.
Depth texture format.
size_t getSliceSkip() const
Get the number of elements between one past the right bottom pixel of one slice and the left top pixe...
Format is in native endian.
PixelFormatFlags
Flags defining some on/off properties of pixel formats.
3 byte pixel format, 1 byte for blue, 1 byte for green, 1 byte for red
PVRTC (PowerVR) RGBA 4 bpp.
DDS (DirectDraw Surface) BC6H format (signed 16 bit float)
ATC (AMD_compressed_ATC_texture)
This is a floating point format.
32-bit pixel format, 8 bits for blue, green, red and alpha.
void * data
The data pointer.
DDS (DirectDraw Surface) BC7 format (unsigned normalised)
PVRTC (PowerVR) RGBA 2 bpp.
Byte per component (8 bit fixed 0.0..1.0)
This format has an alpha channel.
ETC1 (Ericsson Texture Compression)
24-bit pixel format, 8 bits red (unsigned int), 8 bits blue (unsigned int), 8 bits green (unsigned in...
ETC2 (Ericsson Texture Compression)
128-bit pixel format, 32 bits red (unsigned int), 32 bits blue (unsigned int), 32 bits green (unsigne...
96-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue ...
Some utility functions for packing and unpacking pixel data.
DDS (DirectDraw Surface) BC6H format (unsigned 16 bit float)
Unknown pixel format.
32-bit pixel format, 8 bits for red, green, blue and alpha.
96-bit pixel format, 32 bits red (unsigned int), 32 bits blue (unsigned int), 32 bits green (unsigned...
DDS (DirectDraw Surface) DXT3 format.
32-bit pixel format, 8 bits red (unsigned int), 8 bits blue (unsigned int), 8 bits green (unsigned in...
PixelFormat format
The pixel format.
8-bit pixel format, 8 bits red (signed normalised int).
128-bit pixel format, 32 bits red (signed int), 32 bits blue (signed int), 32 bits green (signed int)...
PixelComponentType
Pixel component format.
4 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue, and one byte for alpha ...
48-bit pixel format, 16 bits for red, green and blue
16 bit float per component
24-bit pixel format, 8 bits for blue, green and red.
DDS (DirectDraw Surface) DXT1 format.
Structure used to define a box in a 3-D integer space.
Definition: OgreCommon.h:659
3 byte pixel format, 1 byte for red, 1 byte for green, 1 byte for blue
PVRTC (PowerVR) RGB 2 bpp.
32-bit pixel format, 10 bits for blue, green and red, 2 bits for alpha.
32-bit pixel format, 8 bits for blue, green, red and alpha.
DDS (DirectDraw Surface) DXT2 format.
128-bit pixel format, 32 bits (float) for red, 32 bits (float) for green, 32 bits (float) for blue...
8-bit pixel format, all bits luminance.
16-bit pixel format, 5 bits red, 6 bits green, 5 bits blue.
64-bit pixel format, 32 bits red (unsigned int), 32 bits blue (unsigned int).
32-bit pixel format, 11 bits (float) for red, 11 bits (float) for green, 10 bits (float) for blue ...
64-bit pixel format, 32 bits red (signed int), 32 bits blue (signed int).
PixelFormat
The pixel format used for images, textures, and render surfaces.
32-bit pixel format, 8 bits for red, 8 bits for green, 8 bits for blue like PF_A8R8G8B8, but alpha will get discarded
PixelBox()
Parameter constructor for setting the members manually.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
32-bit, 2-channel s10e5 floating point pixel format, 16-bit green, 16-bit red
unsigned long long uint64
Definition: OgrePlatform.h:355
32-bit pixel format, 16 bits red (signed normalised int), 16 bits blue (signed normalised int)...
16-bit pixel format, 4 bits for alpha, red, green and blue.
size_t slicePitch
Number of elements between the top left pixel of one (depth) slice and the top left pixel of the next...
This is an intensity format instead of a RGB one.
16-bit pixel format, 5 bits for blue, green, red and 1 for alpha.
4 byte pixel format, 1 byte for blue, 1 byte for green, 1 byte for red and one byte for alpha ...
vector< PixelFormat >::type PixelFormatList
16-bit pixel format, 16 bits red (unsigned int).
32-bit pixel format, 8 bits red (signed normalised int), 8 bits blue (signed normalised int)...
16-bit pixel format, 16 bits red (signed int).
unsigned short ushort
PVRTC (PowerVR) Version 2, 2 bpp.
64-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue...
16-bit pixel format, 8 bits red (signed int), 8 bits blue (signed int).
32-bit pixel format, 2 bits for alpha, 10 bits for red, green and blue.
This format is compressed.
DDS (DirectDraw Surface) DXT4 format.
8-bit pixel format, all bits alpha.
24-bit pixel format, 8 bits red (signed normalised int), 8 bits blue (signed normalised int)...
24-bit pixel format, 8 bits red (signed int), 8 bits blue (signed int), 8 bits green (signed int)...
32-bit pixel format, 32 bits red (unsigned int).
24-bit pixel format, 8 bits for red, green and blue.
32-bit pixel format, 8 bits red (signed int), 8 bits blue (signed int), 8 bits green (signed int)...
8-bit pixel format, all bits red.
bool isConsecutive() const
Return whether this buffer is laid out consecutive in memory (ie the pitches are equal to the dimensi...
Unsigned integer per component.
16-bit pixel format, all bits luminance.
96-bit pixel format, 32 bits red (signed int), 32 bits blue (signed int), 32 bits green (signed int)...
_StringBase String
PixelBox(uint32 width, uint32 height, uint32 depth, PixelFormat pixelFormat, void *pixelData=0)
Constructor providing width, height and depth.
PixelBox(const Box &extents, PixelFormat pixelFormat, void *pixelData=0)
Constructor providing extents in the form of a Box object.
32-bit pixel format, 16 bits red (unsigned int), 16 bits blue (unsigned int).
ETC2 (Ericsson Texture Compression)
64-bit pixel format, 16 bits red (signed normalised int), 16 bits blue (signed normalised int)...
64-bit, 2-channel floating point pixel format, 32-bit green, 32-bit red
void setConsecutive()
Set the rowPitch and slicePitch so that the buffer is laid out consecutive in memory.
ATC (AMD_compressed_ATC_texture)
32-bit pixel format, 8 bits for blue, 8 bits for green, 8 bits for red like PF_A8B8G8R8, but alpha will get discarded
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
8-bit pixel format, 2 bits blue, 3 bits green, 3 bits red.
32-bit pixel format, 9 bits for blue, green, red plus a 5 bit exponent.
size_t getRowSkip() const
Get the number of elements between one past the rightmost pixel of one row and the leftmost pixel of ...
64-bit pixel format, 16 bits red (unsigned int), 16 bits blue (unsigned int), 16 bits green (unsigned...
Signed integer per component.
16-bit pixel format, 16 bits (float) for red
16-bit pixel format, 8 bits red (signed normalised int), 8 bits blue (signed normalised int)...
DDS (DirectDraw Surface) BC5 format (unsigned normalised)
2 byte pixel format, 1 byte luminance, 1 byte alpha
48-bit pixel format, 16 bits (float) for red, 16 bits (float) for green, 16 bits (float) for blue ...
DDS (DirectDraw Surface) BC5 format (signed normalised)
This is an integer format.
64-bit pixel format, 16 bits for red, green, blue and alpha
PVRTC (PowerVR) RGB 4 bpp.