Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

# KeosPixelUtils.h File Reference

`#include "KeosPrerequisites.h"`
`#include "KeosLogger.h"`
`#include "KeosConvertPixel.inl"`

Go to the source code of this file.

## Namespaces

namespace | Keos

## Defines

#define | CONVERSIONS_FOR(Fmt)

## Functions

uint | GetBytesPerPixel (TPixelFormat Format)
| Return the number of bytes per pixel / pixel format.
String | FormatToString (TPixelFormat Format)
| Return the name of a pixel format.
bool | FormatCompressed (TPixelFormat Format)
| Test if a format is compressed.
int | GetNbMipLevels (int nWidth, int nHeight)
| Calculate the number of mipmapping levels for a dimension.
template<TPixelFormat SrcFmt, TPixelFormat DestFmt>
void | ConvertPixel (const uchar *pSrc, uchar *pDest)
| Convert a pixel from a format to another.
template<>
void | ConvertPixel< PXF_L8, PXF_L8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_L8, PXF_A8L8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_L8, PXF_A1R5G5B5 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_L8, PXF_A4R4G4B4 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_L8, PXF_R8G8B8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_L8, PXF_A8R8G8B8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A8L8, PXF_L8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A8L8, PXF_A8L8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A8L8, PXF_A1R5G5B5 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A8L8, PXF_A4R4G4B4 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A8L8, PXF_R8G8B8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A8L8, PXF_A8R8G8B8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A1R5G5B5, PXF_L8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A1R5G5B5, PXF_A8L8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A1R5G5B5, PXF_A1R5G5B5 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A1R5G5B5, PXF_A4R4G4B4 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A1R5G5B5, PXF_R8G8B8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A1R5G5B5, PXF_A8R8G8B8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A4R4G4B4, PXF_L8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A4R4G4B4, PXF_A8L8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A4R4G4B4, PXF_A1R5G5B5 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A4R4G4B4, PXF_A4R4G4B4 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A4R4G4B4, PXF_R8G8B8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A4R4G4B4, PXF_A8R8G8B8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_R8G8B8, PXF_L8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_R8G8B8, PXF_A8L8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_R8G8B8, PXF_A1R5G5B5 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_R8G8B8, PXF_A4R4G4B4 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_R8G8B8, PXF_R8G8B8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_R8G8B8, PXF_A8R8G8B8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A8R8G8B8, PXF_L8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A8R8G8B8, PXF_A8L8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A8R8G8B8, PXF_A1R5G5B5 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A8R8G8B8, PXF_A4R4G4B4 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A8R8G8B8, PXF_R8G8B8 > (const uchar *pSrc, uchar *pDest)
template<>
void | ConvertPixel< PXF_A8R8G8B8, PXF_A8R8G8B8 > (const uchar *pSrc, uchar *pDest)
void | ConvertPixel (TPixelFormat SrcFmt, const uchar *pSrc, TPixelFormat DestFmt, uchar *pDest)
| Convert a pixel from a format to another.

## Define Documentation

#define CONVERSIONS_FOR | ( | Fmt |  | ) |

| Value:
    case Fmt : \
                { \
                    switch (DestFmt) \
                    { \
                        case PXF_L8 :       ConvertPixel<Fmt, PXF_L8>(pSrc, pDest);       break; \
                        case PXF_A8L8 :     ConvertPixel<Fmt, PXF_A8L8>(pSrc, pDest);     break; \
                        case PXF_A1R5G5B5 : ConvertPixel<Fmt, PXF_A1R5G5B5>(pSrc, pDest); break; \
                        case PXF_A4R4G4B4 : ConvertPixel<Fmt, PXF_A4R4G4B4>(pSrc, pDest); break; \
                        case PXF_R8G8B8 :   ConvertPixel<Fmt, PXF_R8G8B8>(pSrc, pDest);   break; \
                        case PXF_A8R8G8B8 : ConvertPixel<Fmt, PXF_A8R8G8B8>(pSrc, pDest); break; \
                        case PXF_DXTC1 :    ConvertPixel<Fmt, PXF_DXTC1>(pSrc, pDest);    break; \
                        case PXF_DXTC3 :    ConvertPixel<Fmt, PXF_DXTC3>(pSrc, pDest);    break; \
                        case PXF_DXTC5 :    ConvertPixel<Fmt, PXF_DXTC5>(pSrc, pDest);    break; \
                    } \
                    break; \
                }

## Function Documentation

void ConvertPixel | ( | TPixelFormat | SrcFmt,
|  | const uchar * | pSrc,
|  | TPixelFormat | DestFmt,
|  | uchar * | pDest
| ) | `[inline]`

| Convert a pixel from a format to another.

Parameters:

  | SrcFmt | Source format.
  | pSrc | Pixel to be converted.
  | DestFmt | Destination format.
  | pDest | Result of the conversion.

Definition at line 453 of file KeosPixelUtils.h.

template<TPixelFormat SrcFmt, TPixelFormat DestFmt>
void ConvertPixel | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

| Convert a pixel from a format to another.

Parameters:

  | pSrc | Pixel to be converted.
  | pDest | Result of the conversion.

Definition at line 115 of file KeosPixelUtils.h.

References Keos::FormatToString(), and UNSUPPORTED_EXCEPT.

Referenced by Keos::CImage::CopyImage(), Keos::CImage::GetPixel(), and Keos::CImage::SetPixel().

template<>
void ConvertPixel< PXF_A1R5G5B5, PXF_A1R5G5B5 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A1R5G5B5, PXF_A4R4G4B4 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A1R5G5B5, PXF_A8L8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A1R5G5B5, PXF_A8R8G8B8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A1R5G5B5, PXF_L8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A1R5G5B5, PXF_R8G8B8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A4R4G4B4, PXF_A1R5G5B5 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A4R4G4B4, PXF_A4R4G4B4 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A4R4G4B4, PXF_A8L8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A4R4G4B4, PXF_A8R8G8B8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A4R4G4B4, PXF_L8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A4R4G4B4, PXF_R8G8B8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A8L8, PXF_A1R5G5B5 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A8L8, PXF_A4R4G4B4 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A8L8, PXF_A8L8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A8L8, PXF_A8R8G8B8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A8L8, PXF_L8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A8L8, PXF_R8G8B8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A8R8G8B8, PXF_A1R5G5B5 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A8R8G8B8, PXF_A4R4G4B4 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A8R8G8B8, PXF_A8L8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A8R8G8B8, PXF_A8R8G8B8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A8R8G8B8, PXF_L8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_A8R8G8B8, PXF_R8G8B8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_L8, PXF_A1R5G5B5 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_L8, PXF_A4R4G4B4 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_L8, PXF_A8L8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_L8, PXF_A8R8G8B8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_L8, PXF_L8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_L8, PXF_R8G8B8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_R8G8B8, PXF_A1R5G5B5 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_R8G8B8, PXF_A4R4G4B4 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_R8G8B8, PXF_A8L8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_R8G8B8, PXF_A8R8G8B8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_R8G8B8, PXF_L8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

template<>
void ConvertPixel< PXF_R8G8B8, PXF_R8G8B8 > | ( | const uchar * | pSrc,
|  | uchar * | pDest
| ) | `[inline]`

bool FormatCompressed | ( | TPixelFormat | Format | ) | `[inline]`

| Test if a format is compressed.

Parameters:

  | Format | Pixel format.

Returns:
  True if the format is compressed.

Definition at line 77 of file KeosPixelUtils.h.

References Keos::PXF_DXTC1, Keos::PXF_DXTC3, and Keos::PXF_DXTC5.

Referenced by Keos::CTexture::Load(), and Keos::COGLTexture::Update().

String FormatToString | ( | TPixelFormat | Format | ) | `[inline]`

| Return the name of a pixel format.

Parameters:

  | Format | Pixel format.

Returns:
  String with the format name.

Definition at line 56 of file KeosPixelUtils.h.

References Keos::PXF_A1R5G5B5, Keos::PXF_A4R4G4B4, Keos::PXF_A8L8, Keos::PXF_A8R8G8B8, Keos::PXF_DXTC1, Keos::PXF_DXTC3, Keos::PXF_DXTC5, Keos::PXF_L8, and Keos::PXF_R8G8B8.

Referenced by Keos::ConvertPixel().

uint GetBytesPerPixel | ( | TPixelFormat | Format | ) | `[inline]`

| Return the number of bytes per pixel / pixel format.

Parameters:

  | Format | Pixel format.

Returns:
  Number of bytes per pixel.

Definition at line 35 of file KeosPixelUtils.h.

References Keos::PXF_A1R5G5B5, Keos::PXF_A4R4G4B4, Keos::PXF_A8L8, Keos::PXF_A8R8G8B8, Keos::PXF_DXTC1, Keos::PXF_DXTC3, Keos::PXF_DXTC5, Keos::PXF_L8, and Keos::PXF_R8G8B8.

Referenced by Keos::CImage::CImage(), Keos::CImage::CopyImage(), Keos::CImage::Fill(), Keos::CImage::Flip(), Keos::CImage::GetPixel(), Keos::CImage::Mirror(), Keos::CImagesLoader::SaveToFile(), Keos::CImage::SetPixel(), Keos::CImage::SubImage(), Keos::COGLTexture::Update(), and Keos::CD3D9Texture::UpdateSurface().

int GetNbMipLevels | ( | int | nWidth,
|  | int | nHeight
| ) | `[inline]`

| Calculate the number of mipmapping levels for a dimension.

Parameters:

  | nWidth | Texture width.
  | nHeight | Texture height.

Returns:
  Maximum number of mipmapping levels.

Definition at line 96 of file KeosPixelUtils.h.

Referenced by Keos::COGLRenderSystem::CreateTexture().