Renamed GetBPP to GetBytesPerPixel
Also added GetBitsPerPixel Former-commit-id: 9cc1df58133c538b1dc74215a9022d13dfd9d7f6
This commit is contained in:
@@ -10,7 +10,7 @@ inline bool NzPixelFormat::Convert(nzPixelFormat srcFormat, nzPixelFormat dstFor
|
||||
{
|
||||
if (srcFormat == dstFormat)
|
||||
{
|
||||
std::memcpy(dst, src, GetBPP(srcFormat));
|
||||
std::memcpy(dst, src, GetBytesPerPixel(srcFormat));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ inline bool NzPixelFormat::Convert(nzPixelFormat srcFormat, nzPixelFormat dstFor
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!func(reinterpret_cast<const nzUInt8*>(src), reinterpret_cast<const nzUInt8*>(src) + GetBPP(srcFormat), reinterpret_cast<nzUInt8*>(dst)))
|
||||
if (!func(reinterpret_cast<const nzUInt8*>(src), reinterpret_cast<const nzUInt8*>(src) + GetBytesPerPixel(srcFormat), reinterpret_cast<nzUInt8*>(dst)))
|
||||
{
|
||||
NazaraError("Pixel format conversion from " + ToString(srcFormat) + " to " + ToString(dstFormat) + " failed");
|
||||
return false;
|
||||
@@ -93,7 +93,7 @@ inline bool NzPixelFormat::Flip(nzPixelFlipping flipping, nzPixelFormat format,
|
||||
}
|
||||
#endif
|
||||
|
||||
nzUInt8 bpp = GetBPP(format);
|
||||
nzUInt8 bpp = GetBytesPerPixel(format);
|
||||
unsigned int lineStride = width*bpp;
|
||||
switch (flipping)
|
||||
{
|
||||
@@ -164,93 +164,91 @@ inline bool NzPixelFormat::Flip(nzPixelFlipping flipping, nzPixelFormat format,
|
||||
return true;
|
||||
}
|
||||
|
||||
inline nzUInt8 NzPixelFormat::GetBPP(nzPixelFormat format)
|
||||
inline nzUInt8 NzPixelFormat::GetBitsPerPixel(nzPixelFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case nzPixelFormat_BGR8:
|
||||
return 3;
|
||||
return 24;
|
||||
|
||||
case nzPixelFormat_BGRA8:
|
||||
return 4;
|
||||
return 32;
|
||||
|
||||
case nzPixelFormat_DXT1:
|
||||
return 1;
|
||||
return 8;
|
||||
|
||||
case nzPixelFormat_DXT3:
|
||||
return 2;
|
||||
return 16;
|
||||
|
||||
case nzPixelFormat_DXT5:
|
||||
return 2;
|
||||
return 16;
|
||||
|
||||
case nzPixelFormat_L8:
|
||||
return 1;
|
||||
return 8;
|
||||
|
||||
case nzPixelFormat_LA8:
|
||||
return 2;
|
||||
return 16;
|
||||
/*
|
||||
case nzPixelFormat_RGB16F:
|
||||
return 6;
|
||||
return 48;
|
||||
|
||||
case nzPixelFormat_RGB16I:
|
||||
return 6;
|
||||
return 48;
|
||||
|
||||
case nzPixelFormat_RGB32F:
|
||||
return 12;
|
||||
return 96;
|
||||
|
||||
case nzPixelFormat_RGB32I:
|
||||
return 12;
|
||||
return 96;
|
||||
|
||||
case nzPixelFormat_RGBA16F:
|
||||
return 8;
|
||||
return 64;
|
||||
|
||||
case nzPixelFormat_RGBA16I:
|
||||
return 8;
|
||||
return 64;
|
||||
|
||||
case nzPixelFormat_RGBA32F:
|
||||
return 16;
|
||||
return 128;
|
||||
|
||||
case nzPixelFormat_RGBA32I:
|
||||
return 16;
|
||||
return 128;
|
||||
*/
|
||||
case nzPixelFormat_RGBA4:
|
||||
return 2;
|
||||
return 16;
|
||||
|
||||
case nzPixelFormat_RGB5A1:
|
||||
return 2;
|
||||
return 16;
|
||||
|
||||
case nzPixelFormat_RGB8:
|
||||
return 3;
|
||||
return 24;
|
||||
|
||||
case nzPixelFormat_RGBA8:
|
||||
return 4;
|
||||
return 32;
|
||||
|
||||
case nzPixelFormat_Depth16:
|
||||
return 2;
|
||||
return 16;
|
||||
|
||||
case nzPixelFormat_Depth24:
|
||||
return 3;
|
||||
return 24;
|
||||
|
||||
case nzPixelFormat_Depth24Stencil8:
|
||||
return 4;
|
||||
return 32;
|
||||
|
||||
case nzPixelFormat_Depth32:
|
||||
return 4;
|
||||
return 32;
|
||||
|
||||
case nzPixelFormat_Stencil1:
|
||||
NazaraWarning("This format uses less than one byte per pixel");
|
||||
return 0;
|
||||
|
||||
case nzPixelFormat_Stencil4:
|
||||
NazaraWarning("This format uses less than one byte per pixel");
|
||||
return 0;
|
||||
|
||||
case nzPixelFormat_Stencil8:
|
||||
return 1;
|
||||
|
||||
case nzPixelFormat_Stencil16:
|
||||
case nzPixelFormat_Stencil4:
|
||||
return 2;
|
||||
|
||||
case nzPixelFormat_Stencil8:
|
||||
return 8;
|
||||
|
||||
case nzPixelFormat_Stencil16:
|
||||
return 16;
|
||||
|
||||
case nzPixelFormat_Undefined:
|
||||
break;
|
||||
}
|
||||
@@ -259,6 +257,18 @@ inline nzUInt8 NzPixelFormat::GetBPP(nzPixelFormat format)
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline nzUInt8 NzPixelFormat::GetBytesPerPixel(nzPixelFormat format)
|
||||
{
|
||||
nzUInt8 bytesPerPixel = GetBitsPerPixel(format)/8;
|
||||
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (bytesPerPixel == 0)
|
||||
NazaraWarning("This format is invalid or uses less than one byte per pixel");
|
||||
#endif
|
||||
|
||||
return bytesPerPixel;
|
||||
}
|
||||
|
||||
inline nzPixelFormatType NzPixelFormat::GetType(nzPixelFormat format)
|
||||
{
|
||||
switch (format)
|
||||
|
||||
Reference in New Issue
Block a user