private static void CheckPixelFormat(PixelFormat format)
{
// check pixel format
if (
(format != PixelFormat.Format24bppRgb) &&
(format != PixelFormat.Format8bppIndexed) &&
(format != PixelFormat.Format32bppArgb) &&
(format != PixelFormat.Format32bppRgb)
)
{
throw new UnsupportedImageFormatException("Unsupported pixel format of the source image.");
}
}