Ejemplo n.º 1
0
        //--------------------------------------------------------------------------------------
        public FBordersByColorForImage(Image pImage)
        {
            InitializeComponent();

            fSourceBitmap = pImage as Bitmap;
            if (fSourceBitmap != null)
            {
                pbSourceImage.Image = fSourceBitmap;
            }

            fBlackWhiteExplorer = new CBlackWhiteExplorer();

            Color[] lFinalColors = CBlackWhiteExplorer.DefineExactNeedColor(8);
            fColorsOfVariant = new Color[8];
            fTextOfColors    = new string[8];
            for (int i = 0; i < 6; i++)
            {
                fColorsOfVariant[i + 1] = lFinalColors[i];
            }
            fColorsOfVariant[0] = Color.FromArgb(255, 0, 0, 0);
            fColorsOfVariant[7] = Color.FromArgb(255, 255, 255, 255);
            for (int i = 0; i < fTextOfColors.Length; i++)
            {
                fTextOfColors[i] = fColorsOfVariant[i].R.ToString() + ":" +
                                   fColorsOfVariant[i].G.ToString() + ":" + fColorsOfVariant[i].B.ToString();
            }
            l000.Text              += "   (" + fTextOfColors[0] + ")";
            l001.Text              += "   (" + fTextOfColors[1] + ")";
            l010.Text              += "   (" + fTextOfColors[2] + ")";
            l011.Text              += "   (" + fTextOfColors[3] + ")";
            l100.Text              += "   (" + fTextOfColors[4] + ")";
            l101.Text              += "   (" + fTextOfColors[5] + ")";
            l110.Text              += "   (" + fTextOfColors[6] + ")";
            l111.Text              += "   (" + fTextOfColors[7] + ")";
            l000.BackColor          = fColorsOfVariant[0];
            l001.BackColor          = fColorsOfVariant[1];
            l010.BackColor          = fColorsOfVariant[2];
            l011.BackColor          = fColorsOfVariant[3];
            l100.BackColor          = fColorsOfVariant[4];
            l101.BackColor          = fColorsOfVariant[5];
            l110.BackColor          = fColorsOfVariant[6];
            l111.BackColor          = fColorsOfVariant[7];
            l000.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[0]);
            l001.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[1]);
            l010.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[2]);
            l011.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[3]);
            l100.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[4]);
            l101.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[5]);
            l110.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[6]);
            l111.ForeColor          = CImageSplitter.DefineBestBackColor(fColorsOfVariant[7]);
            fBordersByColorForImage = new CBordersByColorForImage(fSourceBitmap);
        }
Ejemplo n.º 2
0
        //--------------------------------------------------------------------------------------
        private void toolStripButton2_Click_1(object sender, EventArgs e)
        {
            try
            {
                int     lWishColors  = Convert.ToInt32(tstWishfulColos.Text);
                Color[] lRealColors  = CBlackWhiteExplorer.DefineNeedColor(lWishColors);
                Color[] lFinalColors = CBlackWhiteExplorer.DefineExactNeedColor(lWishColors);
                tstSatisfColor.Text = lRealColors.Length.ToString();
                flpColors.Controls.Clear();
                int lNumberInString = 0;
                for (int i = 0; i < lRealColors.Length; i++)
                {
                    Panel lPanel = new Panel();
                    lPanel.BackColor = lRealColors[i];
                    lPanel.Width     = 50;
                    lPanel.Height    = 50;
                    TextBox lLabel = new TextBox();
                    lLabel.Multiline = true;
                    lLabel.Text      = "R:" +
                                       lRealColors[i].R.ToString("G") + Environment.NewLine + " G:" +
                                       lRealColors[i].G.ToString("G") + Environment.NewLine + " B:" +
                                       lRealColors[i].B.ToString("G");
                    lLabel.Width  = 50;
                    lLabel.Height = 50;
//                    lLabel.AutoSize = true;
                    flpColors.Controls.Add(lLabel);
                    flpColors.Controls.Add(lPanel);
                    lNumberInString += 2;
                    if (lNumberInString == 6)
                    {
                        //                        flpColors.SetFlowBreak(flpColors.Controls[flpColors.Controls.Count - 1]);
                        flpColors.SetFlowBreak(lPanel, true);
                        lNumberInString = 0;
                    }
                }
                lNumberInString = 0;
                flpFinalColors.Controls.Clear();
                for (int i = 0; i < lFinalColors.Length; i++)
                {
                    Panel lPanel = new Panel();
                    lPanel.BackColor = lFinalColors[i];
                    lPanel.Width     = 50;
                    lPanel.Height    = 50;
                    TextBox lLabel = new TextBox();
                    lLabel.Multiline = true;
                    lLabel.Text      = "R:" +
                                       lFinalColors[i].R.ToString("G") + Environment.NewLine + " G:" +
                                       lFinalColors[i].G.ToString("G") + Environment.NewLine + " B:" +
                                       lFinalColors[i].B.ToString("G");
                    lLabel.Width  = 50;
                    lLabel.Height = 50;
                    //                    lLabel.AutoSize = true;
                    flpFinalColors.Controls.Add(lLabel);
                    flpFinalColors.Controls.Add(lPanel);
                    lNumberInString += 2;
                    if (lNumberInString == 6)
                    {
                        //                        flpColors.SetFlowBreak(flpColors.Controls[flpColors.Controls.Count - 1]);
                        flpColors.SetFlowBreak(lPanel, true);
                        lNumberInString = 0;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }