public static int GetBytesPerPixel(PixelFormat pixelFormat)
{
int bytesPerPixel;
switch (pixelFormat)
{
case PixelFormat.Indexed8:
bytesPerPixel = 1;
break;
case PixelFormat.Rgb16:
bytesPerPixel = 2;
break;
case PixelFormat.Rgb24:
bytesPerPixel = 3;
break;
default:
throw new ArgumentException(string.Format("Pixel format {0} is not supported", pixelFormat));
}
return bytesPerPixel;
}