⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cwavelet.cs

📁 输入:小波分析的结果或傅立叶分析的结果 输出:图像(bmp) web服务
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;

/// <summary>
/// cwavelet 的摘要说明
/// </summary>
public class cwavelet
{
    int xAxisLength, yAxisLength;
    //double tempVal;      //存放临时值
    double xAxisMin, xAxisMax, yAxisMin, yAxisMax;

	public cwavelet()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}

    public void waveletdraw(int datanumber, double xMin, double xMax, double yMin, double yMax, double[] wavedata, Bitmap basepicture)
    {
        xAxisLength = basepicture.Width - 40;
        yAxisLength = basepicture.Height - 40;
        xAxisMin = xMin;
        xAxisMax = xMax;
        yAxisMin = yMin;
        yAxisMax = yMax;
        Graphics g = Graphics.FromImage(basepicture);
        Point temppoint, nextpoint;
        temppoint = new Point(0, 0);
        nextpoint = new Point(0, 0);
        if (yMax * yMin > 0)
        {
            temppoint.X = 20;
            temppoint.Y = (int)((1 - (wavedata[0] / (yMax))) * yAxisLength + 20);
            for (int i = 0; i < datanumber; i++)
            {
                nextpoint.X = (int)(i * xAxisLength / datanumber + 20);
                nextpoint.Y = (int)((1 - (wavedata[i] / (yMax))) * yAxisLength + 20);

                g.DrawLine(new Pen(new SolidBrush(Color.Black)), temppoint, nextpoint);
                temppoint = nextpoint;
            }

        }
        else
        {
            if (wavedata[0] > 0)
            {
                temppoint.X = 20;
                temppoint.Y = (int)((1 - (wavedata[0] / (yMax))) * yAxisLength / 2 + 20);
            }
            else 
            {
                temppoint.X = 20;
                temppoint.Y = (int)(( wavedata[0] / yMin) * yAxisLength / 2 + yAxisLength / 2 + 20);
            }
            for (int i = 1; i < datanumber; i++)
            {
                
                nextpoint.X = (int)(i * xAxisLength / datanumber + 20);

                if(wavedata[i]>0)
                {
                    nextpoint.Y = (int)((1 - (wavedata[i] / (yMax))) * yAxisLength / 2 + 20);
                }
                else
                {
                    nextpoint.Y = (int)((wavedata[i] / yMin) * yAxisLength / 2 + yAxisLength / 2 + 20);
                }
 
                g.DrawLine(new Pen(new SolidBrush(Color.Black)), temppoint, nextpoint);
                temppoint = nextpoint;
            }

        }
 

    }


}
public class caxis
{

    private int xAxisLength, yAxisLength;
    private int labelnum = 10;
    int xBlock , yBlock; //定义刻度之间的间隔
    string strGrad;     //刻度值
    double tempVal;      //存放临时值
    double xAxisMin , xAxisMax , yAxisMin , yAxisMax;


    public caxis()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }

    public void axisdraw(double xMin, double xMax, double yMin, double yMax, Bitmap basepicture)
    {

        xAxisLength = basepicture.Width-40;
        yAxisLength = basepicture.Height-40;
        xAxisMin = xMin;
        xAxisMax = xMax;
        yAxisMin = yMin;
        yAxisMax = yMax;

        xBlock = xAxisLength / labelnum;
        yBlock = yAxisLength / labelnum;

        Graphics g = Graphics.FromImage(basepicture);
        //绘制y轴
        g.DrawLine(new Pen(new SolidBrush(Color.Black)), new Point(19, 12), new Point(19, yAxisLength + 35));
        g.DrawLine(new Pen(new SolidBrush(Color.Black)), new Point(19, 12), new Point(16, 17));
        g.DrawLine(new Pen(new SolidBrush(Color.Black)), new Point(19, 12), new Point(22, 17));
        //绘制x轴
        g.DrawLine(new Pen(new SolidBrush(Color.Black)), new Point(12, yAxisLength + 20), new Point(xAxisLength + 35, yAxisLength + 20));
        g.DrawLine(new Pen(new SolidBrush(Color.Black)), new Point(xAxisLength + 30, yAxisLength + 17), new Point(xAxisLength + 35, yAxisLength + 20));
        g.DrawLine(new Pen(new SolidBrush(Color.Black)), new Point(xAxisLength + 30, yAxisLength + 23), new Point(xAxisLength + 35, yAxisLength + 20));
        //绘制x轴刻度

        for (int i = 0; i < labelnum + 1; i++)
        {
            g.DrawLine(new Pen(new SolidBrush(Color.Black)), new Point(19 + xBlock * i, yAxisLength + 20), new Point(19 + xBlock * i, yAxisLength + 25));

        }
        //绘制y轴刻度

        for (int i = 0; i < labelnum + 1; i++)
        {
            g.DrawLine(new Pen(new SolidBrush(Color.Black)), new Point(19, yAxisLength + 20 - yBlock * i), new Point(14, yAxisLength + 20 - yBlock * i));

        }
        //绘制x刻度值

        for (int i = 0; i < labelnum + 1; i++)
        {
            tempVal = (((xAxisMax - xAxisMin) / labelnum) * i + xAxisMin);
            strGrad = tempVal.ToString();
            g.DrawString(strGrad, new Font("Courier New", 7), new SolidBrush(Color.Black), (19 + xBlock * i), yAxisLength + 25);
        }
        //绘制y刻度值

        for (int i = 0; i < labelnum + 1; i++)
        {
            tempVal = (((yAxisMax - yAxisMin) / labelnum) * i + yAxisMin);
            strGrad = tempVal.ToString();
            g.DrawString(strGrad, new Font("Courier New", 6), new SolidBrush(Color.Black), 1, (yAxisLength + 20 - yBlock * i));
        }

    }
}
public class cFourier
{
    int xAxisLength, yAxisLength;
    //double tempVal;      //存放临时值
    double xAxisMin, xAxisMax, yAxisMin, yAxisMax;

    public cFourier()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }

    public void Fourierdraw(int datanumber, double xMin, double xMax, double yMin, double yMax, double[] wavedata, Bitmap basepicture)
    {
        xAxisLength = basepicture.Width - 40;
        yAxisLength = basepicture.Height - 40;
        xAxisMin = xMin;
        xAxisMax = xMax;
        yAxisMin = yMin;
        yAxisMax = yMax;
        Graphics g = Graphics.FromImage(basepicture);
        Point temppoint, nextpoint;
        temppoint = new Point(0, 0);
        nextpoint = new Point(0, 0);

        if (yMin > 0)
        {
            for (int i = 0; i < datanumber; i++)
            {
                nextpoint.X = (int)(i * xAxisLength / datanumber + 20);
                nextpoint.Y = (int)((1 - (wavedata[i] / (yMax))) * yAxisLength + 20);

                temppoint.X = (int)(i * xAxisLength / datanumber + 20);
                temppoint.Y = basepicture.Height - 20;

                g.DrawLine(new Pen(new SolidBrush(Color.Black)), temppoint, nextpoint);

            }
        }
        else 
        {
            for (int i = 0; i < datanumber; i++)
            {

                temppoint.X = (int)(i * xAxisLength / datanumber + 20);
                temppoint.Y = basepicture.Height/2 ;

                nextpoint.X = (int)(i * xAxisLength / datanumber + 20);
                if (wavedata[i] > 0)
                {
                    nextpoint.Y = (int)((1 - (wavedata[i] / (yMax))) * yAxisLength /2+ 20);
                }
                else 
                {
                    nextpoint.Y = (int)(((wavedata[i] / (yMin))) * yAxisLength / 2 + yAxisLength / 2 + 20);
                }                
                

                g.DrawLine(new Pen(new SolidBrush(Color.Black)), temppoint, nextpoint);
                //绘制零直线
                g.DrawLine(new Pen(new SolidBrush(Color.Black)), new Point(20, basepicture.Height / 2), new Point(xAxisLength + 35, basepicture.Height / 2));



            }

        }
 

    }


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -