public Color[] GetRecolors(RecolorData recolorData, Dictionary <string, string> defaultOtherNames) { // Go through each ramp to make a dictionary of the color remaps Dictionary <Color, Color> recolors = new Dictionary <Color, Color>(); if (recolorData != null) { for (int i = 0; i < Ramps.Count; i++) { var ramp = GetRamp(i); string name = ramp.Name; if (!recolorData.Recolors.ContainsKey(ramp.Name)) { // If no recolor has this name, check their OtherNames var pair = recolorData.Recolors .FirstOrDefault(x => recolorData.OtherNames(x.Key, defaultOtherNames).Contains(ramp.Name)); if (!string.IsNullOrEmpty(pair.Key)) { name = pair.Key; } else { continue; } } var parameters = recolorData.Recolors[name].Parameters; var recolorPalette = ramp.GetIndexedPalette(parameters); for (int j = 0; j < ramp.Count; j++) { recolors[ramp.GetEntry(j).Value] = recolorPalette.GetColor(j); } } } // Take the original palette and apply all the recolors Color[] result = new Color[Palette.Count]; for (int i = 0; i < Palette.Count; i++) { if (recolors.ContainsKey(Palette[i].Value)) { result[i] = recolors[Palette[i].Value]; } else { result[i] = Palette[i].Color; } } return(result); }
public RecolorData(RecolorData source) { CopyFrom(source); }