private void button6_Click(object sender, EventArgs e) { pictureBox3.Image = bitmap; for (int i = 0; i < 72; i++) { Color color = ProcessFunctions.HSL2RGB(5 * i, 0.5, 0.5); SolidBrush solidBrush = new SolidBrush(color); Pen pen = new Pen(solidBrush, 2); Graphics g2 = pictureBox1.CreateGraphics(); g2.DrawLine(pen, new Point(i * 4 + 2, 20), new Point(i * 4 + 2, 200)); } int maxHuePixel; int[] countHuePixel = new int[73]; ProcessFunctions.Hue_Calculator(bitmap, out maxHuePixel, ref countHuePixel); Graphics g = pictureBox2.CreateGraphics(); Pen curPen = new Pen(Brushes.Black, 1); g.DrawString("色调直方图", new Font("New Timer", 15), Brushes.Black, new Point(139, 10)); g.DrawLine(curPen, 50, 240, 360, 240); g.DrawLine(curPen, 50, 240, 50, 30); g.DrawLine(curPen, 110, 240, 110, 242); g.DrawLine(curPen, 160, 240, 160, 242); g.DrawLine(curPen, 210, 240, 210, 242); g.DrawLine(curPen, 260, 240, 260, 242); g.DrawLine(curPen, 310, 240, 310, 242); g.DrawLine(curPen, 360, 240, 360, 242); g.DrawString("0", new Font("New Timer", 8), Brushes.Black, new PointF(56, 242)); g.DrawString("60", new Font("New Timer", 8), Brushes.Black, new PointF(102, 242)); g.DrawString("120", new Font("New Timer", 8), Brushes.Black, new PointF(149, 242)); g.DrawString("180", new Font("New Timer", 8), Brushes.Black, new PointF(199, 242)); g.DrawString("240", new Font("New Timer", 8), Brushes.Black, new PointF(249, 242)); g.DrawString("300", new Font("New Timer", 8), Brushes.Black, new PointF(299, 242)); g.DrawString("360", new Font("New Timer", 8), Brushes.Black, new PointF(349, 242)); g.DrawLine(curPen, 48, 40, 50, 40); g.DrawString("0", new Font("New Timer", 8), Brushes.Black, new PointF(34, 234)); g.DrawString(maxHuePixel.ToString(), new Font("New Timer", 8), Brushes.Black, new PointF(18, 34)); double temp = 0; for (int i = 0; i < 73; i++) { temp = 200.0 * countHuePixel[i] / maxHuePixel; if (temp > 199) { Console.WriteLine(i); } SolidBrush solidBrush = new SolidBrush(ProcessFunctions.HSL2RGB(5 * i, 0.5, 0.5)); Pen ContPen = new Pen(solidBrush, 2); g.DrawLine(ContPen, (float)(60 + 3.5 * i), 240, (float)(60 + 3.5 * i), 240 - (int)temp); } curPen.Dispose(); }
private void Hsi_Datapicturebox_Layout() { ProcessFunctions.Hue_Calculator(Hsi_nowBmp, out maxHuePixel, ref countHuePixel); Graphics g = tabPage_Hsi.CreateGraphics(); g.Clear(Color.White); int offset_Y = 350; Pen curPen = new Pen(Brushes.Black, 2); g.DrawString("色调直方图", new Font("New Timer", 15), Brushes.Black, new Point(139, 10 + offset_Y)); g.DrawLine(curPen, 50, 240 + offset_Y, 350, 240 + offset_Y); g.DrawLine(curPen, 50, 240 + offset_Y, 50, 30 + offset_Y); g.DrawLine(curPen, 100, 240 + offset_Y, 100, 242 + offset_Y); g.DrawLine(curPen, 150, 240 + offset_Y, 150, 242 + offset_Y); g.DrawLine(curPen, 200, 240 + offset_Y, 200, 242 + offset_Y); g.DrawLine(curPen, 250, 240 + offset_Y, 250, 242 + offset_Y); g.DrawLine(curPen, 300, 240 + offset_Y, 300, 242 + offset_Y); g.DrawLine(curPen, 350, 240 + offset_Y, 350, 242 + offset_Y); g.DrawString("0", new Font("New Timer", 8), Brushes.Black, new PointF(46, 242 + offset_Y)); g.DrawString("60", new Font("New Timer", 8), Brushes.Black, new PointF(92, 242 + offset_Y)); g.DrawString("120", new Font("New Timer", 8), Brushes.Black, new PointF(139, 242 + offset_Y)); g.DrawString("180", new Font("New Timer", 8), Brushes.Black, new PointF(189, 242 + offset_Y)); g.DrawString("240", new Font("New Timer", 8), Brushes.Black, new PointF(239, 242 + offset_Y)); g.DrawString("300", new Font("New Timer", 8), Brushes.Black, new PointF(289, 242 + offset_Y)); g.DrawString("360", new Font("New Timer", 8), Brushes.Black, new PointF(339, 242 + offset_Y)); g.DrawLine(curPen, 48, 40 + offset_Y, 50, 40 + offset_Y); g.DrawString("0", new Font("New Timer", 8), Brushes.Black, new PointF(34, 234 + offset_Y)); g.DrawString(maxHuePixel.ToString(), new Font("New Timer", 8), Brushes.Black, new PointF(18, 34 + offset_Y)); double temp = 0; for (int i = 0; i < 73; i++) { temp = 200.0 * countHuePixel[i] / maxHuePixel; if (temp > 199) { Console.WriteLine(i); } SolidBrush solidBrush = new SolidBrush(ProcessFunctions.HSL2RGB(5 * i, 0.5, 0.5)); Pen ContPen = new Pen(solidBrush, 2); g.DrawLine(ContPen, (float)(60 + 3.5 * i), 240 + offset_Y, (float)(60 + 3.5 * i), 240 - (int)temp + offset_Y); } curPen.Dispose(); }