예제 #1
0
        public void ReplaceColor(CodedImage image, CodedColor oldColor, CodedColor newColor)
        {
            Debug.Assert(ReferenceEquals(Palette, image.Palette), "Image should have same palette.");

            if (oldColor != newColor)
            {
                foreach (var occurrence in oldColor.UsageOccurrences.ToArray())
                {
                    var location = image.GetPixelLocationFromIndex(occurrence);
                    image[location.X, location.Y] = newColor;
                }
                Palette.Remove(oldColor.GetHashCode());
            }
        }