ConvertToTruecolor() public méthode

public ConvertToTruecolor ( int imageNumber, List Palette ) : void
imageNumber int
Palette List
Résultat void
Exemple #1
0
        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();
            }
        }