public int GetPaletteIndex(Color color) { if (Palette == null) { throw new ArgumentNullException(nameof(Palette)); } if (!Palette.Any()) { throw new InvalidOperationException("Cache is empty."); } return(CalculatePaletteIndex(color)); }