Utility/PixelFormat: Add preliminary support for SRGB formats (WIP)
This commit is contained in:
@@ -174,7 +174,9 @@ namespace Nz
|
||||
|
||||
PixelFormat_A8, // 1*uint8
|
||||
PixelFormat_BGR8, // 3*uint8
|
||||
PixelFormat_BGR8_SRGB, // 3*uint8
|
||||
PixelFormat_BGRA8, // 4*uint8
|
||||
PixelFormat_BGRA8_SRGB, // 4*uint8
|
||||
PixelFormat_DXT1,
|
||||
PixelFormat_DXT3,
|
||||
PixelFormat_DXT5,
|
||||
@@ -202,6 +204,7 @@ namespace Nz
|
||||
PixelFormat_RG32UI, // 2*uint32
|
||||
PixelFormat_RGB5A1, // 3*uint5 + alpha bit
|
||||
PixelFormat_RGB8, // 3*uint8
|
||||
PixelFormat_RGB8_SRGB, // 3*uint8
|
||||
PixelFormat_RGB16F, // 3*half
|
||||
PixelFormat_RGB16I, // 4*int16
|
||||
PixelFormat_RGB16UI, // 4*uint16
|
||||
@@ -210,6 +213,7 @@ namespace Nz
|
||||
PixelFormat_RGB32UI, // 4*uint32
|
||||
PixelFormat_RGBA4, // 4*uint4
|
||||
PixelFormat_RGBA8, // 4*uint8
|
||||
PixelFormat_RGBA8_SRGB, // 4*uint8
|
||||
PixelFormat_RGBA16F, // 4*half
|
||||
PixelFormat_RGBA16I, // 4*int16
|
||||
PixelFormat_RGBA16UI, // 4*uint16
|
||||
|
||||
@@ -185,27 +185,14 @@ namespace Nz
|
||||
}
|
||||
#endif
|
||||
|
||||
ConvertFunction func = s_convertFunctions[srcFormat][dstFormat];
|
||||
if (!func)
|
||||
{
|
||||
NazaraError("Pixel format conversion from " + GetName(srcFormat) + " to " + GetName(dstFormat) + " is not supported");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!func(reinterpret_cast<const UInt8*>(src), reinterpret_cast<const UInt8*>(src) + GetBytesPerPixel(srcFormat), reinterpret_cast<UInt8*>(dst)))
|
||||
{
|
||||
NazaraError("Pixel format conversion from " + GetName(srcFormat) + " to " + GetName(dstFormat) + " failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return Convert(srcFormat, dstFormat, src, static_cast<const UInt8*>(src) + GetBytesPerPixel(srcFormat), dst);
|
||||
}
|
||||
|
||||
inline bool PixelFormatInfo::Convert(PixelFormat srcFormat, PixelFormat dstFormat, const void* start, const void* end, void* dst)
|
||||
{
|
||||
if (srcFormat == dstFormat)
|
||||
{
|
||||
std::memcpy(dst, start, reinterpret_cast<const UInt8*>(end)-reinterpret_cast<const UInt8*>(start));
|
||||
std::memcpy(dst, start, reinterpret_cast<const UInt8*>(end) - reinterpret_cast<const UInt8*>(start));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user