⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hslfilter.cs

📁 破解的飞信源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
                        if (num10 < 60)
                        {
                            num5 = num17 + ((num19 * num10) * 0.016666666666666666);
                        }
                        else if (num10 < 180)
                        {
                            num5 = num18;
                        }
                        else if (num10 < 240)
                        {
                            num5 = num17 + (num19 * (4 - (num10 * 0.016666666666666666)));
                        }
                        else
                        {
                            num5 = num17;
                        }
                        num10 = num7 - 120;
                        if (num10 < 0)
                        {
                            num10 += 360;
                        }
                        if (num10 < 60)
                        {
                            num6 = num17 + ((num19 * num10) * 0.016666666666666666);
                        }
                        else if (num10 < 180)
                        {
                            num6 = num18;
                        }
                        else if (num10 < 240)
                        {
                            num6 = num17 + (num19 * (4 - (num10 * 0.016666666666666666)));
                        }
                        else
                        {
                            num6 = num17;
                        }
                    }
                    destination[index + 2] = (byte) num4;
                    destination[index + 1] = (byte) num5;
                    destination[index] = (byte) num6;
                }
            }
            Marshal.Copy(destination, 0, source, length);
            bitmap.UnlockBits(bitmapdata);
            return bitmap;
        }

        protected unsafe void ProcessFilter(BitmapData imageData)
        {
            int width = imageData.Width;
            int height = imageData.Height;
            int num3 = imageData.Stride - (width * 3);
            RGB rgb = new RGB();
            HSL hsl = new HSL();
            double num4 = 0;
            double num5 = 0;
            double num6 = 0;
            double num7 = 0;
            if (this.inLuminance.Max != this.inLuminance.Min)
            {
                num4 = (this.outLuminance.Max - this.outLuminance.Min) / (this.inLuminance.Max - this.inLuminance.Min);
                num5 = this.outLuminance.Min - (num4 * this.inLuminance.Min);
            }
            if (this.inSaturation.Max != this.inSaturation.Min)
            {
                num6 = (this.outSaturation.Max - this.outSaturation.Min) / (this.inSaturation.Max - this.inSaturation.Min);
                num7 = this.outSaturation.Min - (num6 * this.inSaturation.Min);
            }
            byte* numPtr = (byte*) imageData.Scan0.ToPointer();
            for (int i = 0; i < height; i++)
            {
                int num9 = 0;
                while (num9 < width)
                {
                    rgb.Red = numPtr[2];
                    rgb.Green = numPtr[1];
                    rgb.Blue = numPtr[0];
                    if (((base.BackgroundColor.R == rgb.Red) && (base.BackgroundColor.G == rgb.Green)) && (base.BackgroundColor.B == rgb.Blue))
                    {
                        num9++;
                        numPtr += 3;
                    }
                    else
                    {
                        Imps.Client.Utils.ColorConverter.RGB2HSL(rgb, hsl);
                        if (hsl.Luminance >= this.inLuminance.Max)
                        {
                            hsl.Luminance = this.outLuminance.Max;
                        }
                        else if (hsl.Luminance <= this.inLuminance.Min)
                        {
                            hsl.Luminance = this.outLuminance.Min;
                        }
                        else
                        {
                            hsl.Luminance = (num4 * hsl.Luminance) + num5;
                        }
                        if (hsl.Saturation >= this.inSaturation.Max)
                        {
                            hsl.Saturation = this.outSaturation.Max;
                        }
                        else if (hsl.Saturation <= this.inSaturation.Min)
                        {
                            hsl.Saturation = this.outSaturation.Min;
                        }
                        else
                        {
                            hsl.Saturation = (num6 * hsl.Saturation) + num7;
                        }
                        hsl.Hue += this.adjustHueValue;
                        if (hsl.Hue > 360)
                        {
                            hsl.Hue -= 360;
                        }
                        Imps.Client.Utils.ColorConverter.HSL2RGB(hsl, rgb);
                        numPtr[2] = rgb.Red;
                        numPtr[1] = rgb.Green;
                        numPtr[0] = rgb.Blue;
                        num9++;
                        numPtr += 3;
                    }
                }
                numPtr += num3;
            }
        }

        private int AdjustHueValue
        {
            set
            {
                this.adjustHueValue = value;
                while (this.adjustHueValue < 0)
                {
                    this.adjustHueValue += 360;
                }
                while (this.adjustHueValue >= 360)
                {
                    this.adjustHueValue -= 360;
                }
            }
        }

        private double AdjustLuminanceValue
        {
            set
            {
                this.adjustLuminanceValue = Math.Max(-1, Math.Min(1, value));
                if (this.adjustLuminanceValue > 0)
                {
                    this.inLuminance = new DoubleRange(0, 1 - this.adjustLuminanceValue);
                    this.outLuminance = new DoubleRange(this.adjustLuminanceValue, 1);
                }
                else
                {
                    this.inLuminance = new DoubleRange(-this.adjustLuminanceValue, 1);
                    this.outLuminance = new DoubleRange(0, 1 + this.adjustLuminanceValue);
                }
            }
        }

        private double AdjustSaturationValue
        {
            set
            {
                this.adjustSaturationValue = Math.Max(-1, Math.Min(1, value));
                if (this.adjustSaturationValue > 0)
                {
                    this.inSaturation = new DoubleRange(0, 1 - this.adjustSaturationValue);
                    this.outSaturation = new DoubleRange(this.adjustSaturationValue, 1);
                }
                else
                {
                    this.inSaturation = new DoubleRange(-this.adjustSaturationValue, 1);
                    this.outSaturation = new DoubleRange(0, 1 + this.adjustSaturationValue);
                }
            }
        }

        public double Hue
        {
            get
            {
                return this._hue;
            }
            set
            {
                this._hue = value;
                this.AdjustHueValue = (int) value;
            }
        }

        public double Lightness
        {
            get
            {
                return this._lightness;
            }
            set
            {
                if ((value >= -100) && (value <= 100))
                {
                    this._lightness = value;
                    this.AdjustLuminanceValue = (value / 100) / 1.5;
                }
            }
        }

        public double Saturation
        {
            get
            {
                return this._saturation;
            }
            set
            {
                if ((value >= -100) && (value <= 100))
                {
                    this._saturation = value;
                    this.AdjustSaturationValue = value / 100;
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -