コード例 #1
0
ファイル: Form_Di_anepp.cs プロジェクト: GDanovski/Di-anepp
        private void LoadBitmap()
        {
            #region Create LUT
            double B = double.Parse(textBox_Brightness.Text);

            Color[] LUT = new Color[256];

            int start = DoubleToHue(double.Parse(textBox_Min.Text));
            int stop  = DoubleToHue(double.Parse(textBox_Max.Text));

            for (int i = 0; i < start; i++)
            {
                LUT[i] = MyColorTranslator.ColorFromHSV(255, 1, B);
            }

            for (int i = stop; i < 256; i++)
            {
                LUT[i] = MyColorTranslator.ColorFromHSV(0, 1, B);
            }

            double step = (double)250 / (stop - start);

            double val = 0;
            for (int i = stop - 1; i >= start; i--, val += step)
            {
                LUT[i] = MyColorTranslator.ColorFromHSV(val, 1, B);
            }

            //for (int b = 255, g = 0; g < 256; g++, b--)
            //LUT[g] = Color.FromArgb(0, g, b);
            #endregion Create LUT

            Bitmap bmp = new Bitmap(fi.sizeX, fi.sizeY);

            BitMapEditor.LockBitmap bmpEditor = new BitMapEditor.LockBitmap(bmp);
            bmpEditor.LockBits();

            for (int y = 0, pointer = 0; y < bmpEditor.Height; y++)
            {
                for (int x = 0; x < bmpEditor.Width; x++, pointer++)
                {
                    if (GPImg[pointer] == -100)
                    {
                        bmpEditor.SetPixel(x, y, Color.FromArgb(0, 0, 0));
                    }
                    else
                    {
                        for (int i = 0; i < GPc.Length; i++)
                        {
                            if (GPImg[pointer] <= GPc[i])
                            {
                                bmpEditor.SetPixel(x, y, LUT[i]);
                                break;
                            }
                        }
                    }
                }
            }

            /*
             * bmpEditor.SetPixel(x, y, MyColorTranslator.ColorFromHSV(((GPImg[pointer] + 1) / 2)*360, 1, 1));
             * //bmpEditor.SetPixel(x, y, MyColorTranslator.FromAhsb(255,(float)((GPImg[pointer] + 1) / 2) * 360, 1.0f, 1.0f));
             *
             * for (int y = 0, pointer = 0; y < 255; y++)
             * for (int x = 0; x < bmpEditor.Width; x++, pointer++)
             * bmpEditor.SetPixel(x, y, MyColorTranslator.ColorFromHSV(y, 1, 1));
             * //bmpEditor.SetPixel(x, y, MyColorTranslator.FromAhsb(255, (float)y, 1.0f, 1.0f));
             * /*
             *
             * for (int i = 0; i < GPc.Length; i++)
             * if (GPImg[pointer] <= GPc[i])
             * {
             * bmpEditor.SetPixel(x, y, LUT[i]);
             * break;
             * }*/

            bmpEditor.UnlockBits();

            pictureBox1.Width  = fi.sizeX;
            pictureBox1.Height = fi.sizeY;
            pictureBox1.Image  = bmp;
        }
コード例 #2
0
ファイル: Form_Di_anepp.cs プロジェクト: GDanovski/Di-anepp
        private void LoadColorBar()
        {
            #region Create LUT
            double B = double.Parse(textBox_Brightness.Text);

            Color[] LUT = new Color[pictureBox2.Width];

            int    stop = pictureBox2.Width;
            double step = (double)250 / (stop);
            double val  = 0;
            for (int i = stop - 1; i >= 0; i--, val += step)
            {
                LUT[i] = MyColorTranslator.ColorFromHSV(val, 1, B);
            }

            #endregion Create LUT

            Bitmap bmp = new Bitmap(pictureBox2.Width, pictureBox2.Height);

            BitMapEditor.LockBitmap bmpEditor = new BitMapEditor.LockBitmap(bmp);
            bmpEditor.LockBits();

            for (int y = 0, pointer = 0; y < bmpEditor.Height; y++)
            {
                for (int x = 0; x < bmpEditor.Width; x++, pointer++)
                {
                    bmpEditor.SetPixel(x, y, LUT[x]);
                }
            }

            bmpEditor.UnlockBits();
            pictureBox2.Image = bmp;

            //vals
            {
                double start     = double.Parse(textBox_Min.Text);
                double increment = (double.Parse(textBox_Max.Text) - start) / 4;

                label_val_1.Text = Math.Round(start, 2).ToString();
                start           += increment;
                label_val_2.Text = Math.Round(start, 2).ToString();
                start           += increment;
                label_val_3.Text = Math.Round(start, 2).ToString();
                start           += increment;
                label_val_4.Text = Math.Round(start, 2).ToString();
                label_val_5.Text = Math.Round(double.Parse(textBox_Max.Text), 1).ToString();
            }
            //width
            {
                double start     = pictureBox2.Location.X;
                double increment = pictureBox2.Width / 4;

                label_val_1.Location = new Point((int)start - TextRenderer.MeasureText(label_val_1.Text, label_val_1.Font).Width / 2, label_val_1.Location.Y);
                start += increment;
                label_val_2.Location = new Point((int)start - TextRenderer.MeasureText(label_val_2.Text, label_val_2.Font).Width / 2, label_val_1.Location.Y);
                start += increment;
                label_val_3.Location = new Point((int)start - TextRenderer.MeasureText(label_val_3.Text, label_val_3.Font).Width / 2, label_val_1.Location.Y);
                start += increment;
                label_val_4.Location = new Point((int)start - TextRenderer.MeasureText(label_val_4.Text, label_val_4.Font).Width / 2, label_val_1.Location.Y);
                start += increment;
                label_val_5.Location = new Point((int)start - TextRenderer.MeasureText(label_val_5.Text, label_val_5.Font).Width / 2, label_val_1.Location.Y);
            }
        }