private bool CheckIfGrayScale(PixelFormat pixelFormat, BitmapPalette palette, DeepScanOptions DeepScan) { if (pixelFormat == PixelFormats.Gray32Float || pixelFormat == PixelFormats.Gray16 || pixelFormat == PixelFormats.Gray8 || pixelFormat == PixelFormats.Gray4 || pixelFormat == PixelFormats.Gray2) { if (DeepScan != DeepScanOptions.Force) { return(true); } else if (pixelFormat == PixelFormats.Indexed8 || pixelFormat == PixelFormats.Indexed4 || pixelFormat == PixelFormats.Indexed2) { DeepScan = (DeepScan != DeepScanOptions.Skip) ? DeepScanOptions.Force : DeepScan; } } if ((DeepScan != DeepScanOptions.Skip) & palette != null) { List <Color> IndexedColors = palette.Colors.ToList(); return(IndexedColors.All(rgb => (rgb.R == rgb.G && rgb.G == rgb.B && rgb.B == rgb.R))); } return(false); }
public bool IsGrayScale(DeepScanOptions DeepScan) { return(CheckIfGrayScale(this.PixelFormat, this.Palette, DeepScan)); }