110,566
社区成员
发帖
与我相关
我的任务
分享
public static Bitmap writeImage(Bitmap image,double[] dubleY1, double[] DubleY2, int[] xLine1,int[] xLine2, double yStart, double yUnit, int xUnit, string yName,int tt,int xStart)
{
Pen p1 = Pens.Blue; //写图例的画笔
Pen p2 = Pens.Red;
Brush bs1 = Brushes.Blue; //画线用的
Brush bs2 = Brushes.Red;
int[] y1 = getYpoint1(dubleY1, yStart, yUnit); //Y轴的坐标点
int[] y2 = getYpoint1(DubleY2, yStart, yUnit); //Y轴的坐标点
//Bitmap image = Resource2.KT3;//线图底稿
Bitmap newimage = new Bitmap(image.Width, image.Height);
Graphics oGraphic = Graphics.FromImage(newimage);
Point p00 = new Point(0, 0);
oGraphic.DrawImage(image, p00);
image.Dispose();
image = newimage;
Point[] py1 = new Point[y1.Length];
Point[] py2 = new Point[y2.Length];
……这里有一段得到Y 点数组的代码,取得每个Y点的位置
using (Graphics g = Graphics.FromImage(image)) //在背景图上画 折线图
{
if (py1.Length > 1)
{
g.DrawLines(p1, py1);//标准值 曲线
}
if (py2.Length > 1)
{
g.DrawLines(p2, py2);//检测值 曲线
}
//画y轴坐标
for (int i = 0; i <7; i++)
{
double iYvalue = yStart + yUnit * 20 * i;
g.DrawString(iYvalue.ToString("0.00"), ft, bs2, theYs[i]);
}
//画x轴坐标
for (int i = 0; i <5; i++)
{
string xValue = "0";
int theXvalue = (i * xUnit + 1) * 50;
xValue = Convert.ToInt32(i * 5 * xUnit+xStart).ToString();
g.DrawString(xValue, ft, Brushes.White, theXs[i]);
}
//画出图例
int leng = yName.Length;
Point pA;
Point pB;
switch (tt)
{
case 0:
pA = new Point(700, 20);
pB = new Point(700, 35);
^ default:
pA = new Point(1820, 1160);
pB = new Point(1820, 1175);
break;
}
g.DrawString("[" + yName + ":标准值]", ft2, bs1, pA);
g.DrawString("[" + yName + ":检测值]", ft2, bs2, pB);
}
return image;
}