public ConvertToTruecolor ( int imageNumber, List |
||
imageNumber | int | |
Palette | List |
|
리턴 | void |
public void HomogenizePalette() { ImageSection isec = null; PaletteSection psec = null; foreach (var section in Sections) { if (section.GetType() == typeof(ImageSection)) { isec = (ImageSection)section; } if (section.GetType() == typeof(PaletteSection)) { psec = (PaletteSection)section; } } for (int i = 0; i < isec.ImageCount; ++i) { isec.DiscardUnusedColorsPaletted(i, psec, i); } List <uint> PaletteList = new List <uint>(); foreach (List <uint> pal in psec.Palettes) { PaletteList.AddRange(pal); } List <uint> NewPalette = PaletteList.Distinct().ToList(); int maxColors = 1 << isec.ColorDepth; if (NewPalette.Count > maxColors) { string err = "ERROR: Combined Palette over the amount of allowed colors. (" + NewPalette.Count + " > " + maxColors + ")"; Console.WriteLine(err); throw new Exception(err); } while (NewPalette.Count < maxColors) { NewPalette.Add(0); } for (int i = 0; i < isec.ImageCount; ++i) { isec.ConvertToTruecolor(i, psec.Palettes[i]); isec.CovertToPaletted(i, NewPalette.ToArray()); psec.Palettes[i] = NewPalette.ToList(); } }