예제 #1
0
        public bool Initialize()
        {
            if (((currentMode == Mode.Asset && assetType == AssetType.EMO) || currentMode == Mode.Global) && !SettingsManager.Instance.LoadTextures)
            {
                MessageBox.Show("This option is not available while textures are turned off. Enable Load Textures in the settings to use this option.", "Not Available", MessageBoxButton.OK, MessageBoxImage.Warning);
                return(false);
            }

            List <RgbColor> colors = null;

            if (currentMode == Mode.Asset)
            {
                colors = asset.GetUsedColors();
            }
            else if (currentMode == Mode.Material)
            {
                colors = material.GetUsedColors();
            }
            else if (currentMode == Mode.Global)
            {
                colors = GetUsedColorsByEverything();
            }
            else if (currentMode == Mode.ParticleEffect)
            {
                colors = particleEffect.GetUsedColors();
            }


            if (colors.Count == 0)
            {
                MessageBox.Show("No color information was found on this asset so it cannot be hue shifted.\n\nThe most likely cause of this is that all color sources for this asset were either all white (1,1,1) or all black (0,0,0).", "No color information", MessageBoxButton.OK, MessageBoxImage.Warning);
                return(false);
            }

            rgbColor = ColorEx.GetAverageColor(colors);
            hslColor = rgbColor.ToHsl();

            //hslColor.Lightness = 0.5f; //Gives a "pure" color. Not light or dark. Good for previewing.
            //hslColor.Saturation = 1f; //Completely saturated. Good for previewing.
            initialHue        = hslColor.Hue;
            initialSaturation = hslColor.Saturation;
            initialLightness  = hslColor.Lightness;

            ValueChanged();

            return(true);
        }
예제 #2
0
        public RgbColor GetDdsColor()
        {
            if (DdsImage == null)
            {
                throw new InvalidOperationException("GetDdsColor: DdsImage was null.");
            }
            List <RgbColor> colors = new List <RgbColor>();

            //Lazy code. Checking every single pixel would be WAY too slow, so we just skim through them instead.
            for (int i = 0; i < DdsImage.Width; i += 15)
            {
                if (i > DdsImage.Width)
                {
                    break;
                }

                for (int a = 0; a < DdsImage.Height; a += 15)
                {
                    if (a > DdsImage.Height)
                    {
                        break;
                    }

                    var      pixel    = DdsImage.GetPixel(i, a);
                    RgbColor rgbColor = new RgbColor(pixel.R, pixel.G, pixel.B);

                    if (!rgbColor.IsWhiteOrBlack)
                    {
                        colors.Add(rgbColor);
                    }
                }
            }

            if (colors.Count == 0)
            {
                return(new RgbColor(255, 255, 255));
            }

            return(ColorEx.GetAverageColor(colors));
        }
예제 #3
0
        private void SetInitialColor()
        {
            List <RgbColor> colors = null;

            if (currentMode == Mode.Asset)
            {
                colors = asset.GetUsedColors();
            }
            else if (currentMode == Mode.Material)
            {
                colors = material.GetUsedColors();
            }
            else if (currentMode == Mode.Global)
            {
                colors = GetUsedColorsByEverything();
            }
            else if (currentMode == Mode.ParticleEffect)
            {
                colors = particleEffect.GetUsedColors();
            }


            if (colors.Count == 0)
            {
                Close();
                MessageBox.Show("No color information was found on this asset so it cannot be hue shifted.\n\nThe most likely cause of this is that all color sources for this asset were either all white (1,1,1) or all black (0,0,0).", "No color information", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            rgbColor = ColorEx.GetAverageColor(colors);
            hslColor = rgbColor.ToHsl();

            //hslColor.Lightness = 0.5f; //Gives a "pure" color. Not light or dark. Good for previewing.
            //hslColor.Saturation = 1f; //Completely saturated. Good for previewing.
            initialHue        = hslColor.Hue;
            initialSaturation = hslColor.Saturation;
            initialLightness  = hslColor.Lightness;

            ValueChanged();
        }