Esempio n. 1
0
        public static bool ColorSlantsDarkOrBright(Color c)
        {
            HSL hsl = ColorConverterEx.smethod_0(c);

            if (hsl.Luminance < 0.15 || hsl.Luminance < 0.35)
            {
                return(true);
            }
            return(hsl.Luminance < 0.85 ? false : false);
        }
Esempio n. 2
0
        private void dSkinButton_BackGround_Click(object sender, EventArgs e)
        {
            bool           bbb            = dSkinCheckBox_ImageFuzzy.Checked;
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter      = "Image Files(*.All Types)|*.jpg;*.jpeg;*.png;*.bmp;*.gif";
            openFileDialog.FilterIndex = 1;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                System.IO.FileInfo fl = new System.IO.FileInfo(openFileDialog.FileName);
                if (fl.Length > 1024 * 1024)
                {
                    //System.Windows.Forms.MessageBox.Show("请选择1M以内的横向图片");
                    AuroraMessageBox msg = null;
                    msg               = new AuroraMessageBox();
                    msg.strCaption    = "Aurora智能提示";
                    msg.strMessage    = "请选择1M以内的横向图片";
                    msg.strButtonText = "确定";
                    msg.StartPosition = FormStartPosition.Manual;
                    msg.Location      = new Point(this.Location.X + this.Width / 2 - msg.Width / 2, this.Location.Y + this.Height / 2 - msg.Height / 2);
                    msg.ShowDialog();
                    return;
                }
                mainFrm.str_BackGroundImage = dSkinTextBox_BackGround.Text = openFileDialog.FileName;
                mainFrm.SetPlayerBackground();
                mainFrm.ItemHoverColor = SkinTools.GetImageAverageColor(Image.FromFile(openFileDialog.FileName));
                HSL hsl = ColorConverterEx.ColorToHSL(mainFrm.ItemHoverColor);
                //hsl.Luminance += 0.2;
                //if (hsl.Luminance >= 1)
                //    hsl.Luminance = 0.99;
                hsl.Saturation += 0.2;
                if (hsl.Saturation >= 1)
                {
                    hsl.Saturation = 0.99;
                }
                mainFrm.ItemHoverColor           = ColorConverterEx.HSLToColor(hsl);
                dSkinCheckBox_ImageFuzzy.Checked = !bbb;
                dSkinCheckBox_ImageFuzzy.Checked = bbb;
                this.Invalidate();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 判断颜色偏向于暗色或亮色(true为偏向于暗色,false位偏向于亮色。)
        /// </summary>
        /// <param name="c">要判断的颜色</param>
        /// <returns>true为偏向于暗色,false位偏向于亮色。</returns>
        public static bool ColorSlantsDarkOrBright(Color c)
        {
            HSL hsl = ColorConverterEx.ColorToHSL(c);

            if (hsl.Luminance < 0.15d)
            {
                return(true);
            }
            else if (hsl.Luminance < 0.35d)
            {
                return(true);
            }
            else if (hsl.Luminance < 0.85d)
            {
                return(false);
            }
            else
            {
                return(false);
            }
        }
        private void DrawDefaultBack(Graphics g, RectangleF rect)
        {
            float width = rect.Width / 360f;

            rect.Width = width;
            using (LinearGradientBrush brush = new LinearGradientBrush(
                       new Point(0, 0), new Point(1, 0), Color.White, Color.White))
            {
                ColorBlend blend = new ColorBlend();
                blend.Colors    = new Color[] { Color.White, Color.White, Color.Black };
                blend.Positions = new float[] { 0f, .5f, 1f };
                brush.Transform = new Matrix(0f, rect.Height, 1f, 0f, 0f, 0f);
                for (int i = 0; i < 360; i++)
                {
                    _drawHsl.Hue              = i;
                    rect.X                   += width;
                    blend.Colors[1]           = ColorConverterEx.HSLToColor(_drawHsl);
                    brush.InterpolationColors = blend;
                    g.FillRectangle(brush, rect);
                }
            }
        }
Esempio n. 5
0
        private void CalcColors()
        {
            switch (_barStyle)
            {
            case HSLTrackBarStyle.Saturation:
                if (_blend == null)
                {
                    _blend = new ColorBlend();
                }
                HSL     hsl    = _hsl;
                Color[] colors = new Color[3];
                hsl.Saturation = 1d;
                colors[2]      = ColorConverterEx.HSLToColor(hsl);
                hsl.Saturation = 0.5d;
                colors[1]      = ColorConverterEx.HSLToColor(hsl);
                hsl.Saturation = 0d;
                colors[0]      = ColorConverterEx.HSLToColor(hsl);

                _blend.Colors    = colors;
                _blend.Positions = new float[] { 0, 0.5f, 1f };
                break;
            }
        }
Esempio n. 6
0
 private Color GetGray(Color color)
 {
     return(ColorConverterEx.RgbToGray(
                new RGB(color)).Color);
 }