namespace Quik.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; } } } }