Due to unforseen naming conflicts, the project has been rebranded under the ReFuel umbrealla and will now be referred to as Dashboard from now on. Other changes will occur to suit the library more for the engine whilst keeping the freestanding nature of the library. Rename folder. Rename to Dashboard.OpenTK Rename to Dashboard.Media.Defaults. Do the last renames and path fixes.
71 lines
2.4 KiB
C#
71 lines
2.4 KiB
C#
namespace Dashboard.Media
|
|
{
|
|
public static class Extensions
|
|
{
|
|
public static bool IsU8(this QImageFormat format)
|
|
{
|
|
switch (format)
|
|
{
|
|
case QImageFormat.AlphaU8:
|
|
case QImageFormat.RedU8:
|
|
case QImageFormat.RaU8:
|
|
case QImageFormat.RgbU8:
|
|
case QImageFormat.RgbaU8:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static bool IsFloat(this QImageFormat format)
|
|
{
|
|
switch (format)
|
|
{
|
|
case QImageFormat.AlphaF:
|
|
case QImageFormat.RedF:
|
|
case QImageFormat.RaF:
|
|
case QImageFormat.RgbF:
|
|
case QImageFormat.RgbaF:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static int BytesPerPixel(this QImageFormat format)
|
|
{
|
|
switch (format)
|
|
{
|
|
case QImageFormat.AlphaU8: return sizeof(byte);
|
|
case QImageFormat.RedU8: return sizeof(byte);
|
|
case QImageFormat.RaU8: return 2 * sizeof(byte);
|
|
case QImageFormat.RgbU8: return 3 * sizeof(byte);
|
|
case QImageFormat.RgbaU8: return 4 * sizeof(byte);
|
|
case QImageFormat.AlphaF: return sizeof(float);
|
|
case QImageFormat.RedF: return sizeof(float);
|
|
case QImageFormat.RaF: return 2 * sizeof(float);
|
|
case QImageFormat.RgbF: return 3 * sizeof(float);
|
|
case QImageFormat.RgbaF: return 4 * sizeof(float);
|
|
default: return 0;
|
|
}
|
|
}
|
|
|
|
public static int Channels(this QImageFormat format)
|
|
{
|
|
switch (format)
|
|
{
|
|
case QImageFormat.AlphaU8: return 1;
|
|
case QImageFormat.RedU8: return 1;
|
|
case QImageFormat.RaU8: return 2;
|
|
case QImageFormat.RgbU8: return 3;
|
|
case QImageFormat.RgbaU8: return 4;
|
|
case QImageFormat.AlphaF: return 1;
|
|
case QImageFormat.RedF: return 1;
|
|
case QImageFormat.RaF: return 2;
|
|
case QImageFormat.RgbF: return 3;
|
|
case QImageFormat.RgbaF: return 4;
|
|
default: return 0;
|
|
}
|
|
}
|
|
}
|
|
} |