Ejemplo n.º 1
0
        protected override void RestoreImageSettingsCore(CodedImage image)
        {
            base.RestoreImageSettingsCore(image);

            using (SuspendCallManipulations())
            {
                PaletteName = image.Palette.Name;

                int maxColorsValue;
                MaxColorsCount = image.TryGetAdditionalValueAsInt(nameof(MaxColorsCount), out maxColorsValue) ? maxColorsValue : image.Palette.Count;

                string comparisonTypeValue;
                if (image.TryGetAdditionalDataAsString(nameof(ColorComparisonType), out comparisonTypeValue))
                {
                    ColorComparisonTypes comparisonType;
                    if (Enum.TryParse(comparisonTypeValue, out comparisonType))
                    {
                        ColorComparisonType = comparisonType;
                    }
                }

                bool ensureBlackAndWhiteValue;
                if (image.TryGetAdditionalValueAsBool(nameof(EnsureBlackAndWhiteColors), out ensureBlackAndWhiteValue))
                {
                    EnsureBlackAndWhiteColors = ensureBlackAndWhiteValue;
                }

                int ditherLevelValue;
                if (image.TryGetAdditionalValueAsInt(nameof(DitherLevel), out ditherLevelValue))
                {
                    DitherLevel = ditherLevelValue;
                }
            }
        }