获取股票的瞬时图C#

获取时时线。欢迎转载啊。 

private void getnewpic(string num)

        {

            try

            {

                string url = @"http://image2.sinajs.cn/newchart/min/n/sh" + num + ".gif";

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);



                System.IO.Stream s = request.GetResponse().GetResponseStream();

                Image img2 = System.Drawing.Bitmap.FromStream(s);

                s.Close();

                //生成Bitmap对像

                Bitmap img = new Bitmap(img2, 545, 300);

                //生成绘图对像

                Graphics g = Graphics.FromImage(img);

                //定义黑色画笔

                Pen Bp = new Pen(Color.Black);

                LinearGradientBrush Bluebrush = new LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Color.Blue, Color.Blue, 1.2F, true);

                LinearGradientBrush Transpentbrush = new LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Form1.DefaultBackColor, Form1.DefaultBackColor, 1.2F, true);

                //string info = " 曲线图生成时间:" + DateTime.Now.ToString();

                Font Tfont = new Font("Arial", 9);

                //g.DrawString(info, Tfont, Bluebrush, 40, 25);

                g.FillRectangle(Transpentbrush, 5, 287, 535, 15);

                g.FillRectangle(Transpentbrush, 497, 228, 35, 30);



                //保存绘制的图片

                MemoryStream stream = new MemoryStream();

                img.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);

                this.pictureBox1.Image = img;

            }

            catch (Exception ex)

            { 

            }

        }




获取日K线。

private void getKpic(string num)

        {

            try

            {

                string url = @"http://image2.sinajs.cn/newchart/daily/n/sh" + num + ".gif";

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);



                System.IO.Stream s = request.GetResponse().GetResponseStream();

                Image img2 = System.Drawing.Bitmap.FromStream(s);

                s.Close();

                //生成Bitmap对像

                Bitmap img = new Bitmap(img2,545, 300);

                //生成绘图对像

                Graphics g = Graphics.FromImage(img);

                //定义黑色画笔

                Pen Bp = new Pen(Color.Black);

                LinearGradientBrush Bluebrush = new LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Color.Blue, Color.Blue, 1.2F, true);

                LinearGradientBrush Transpentbrush = new LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Form1.DefaultBackColor, Form1.DefaultBackColor, 1.2F, true);

                //string info = " 曲线图生成时间:" + DateTime.Now.ToString();

                Font Tfont = new Font("Arial", 9);

                //g.DrawString(info, Tfont, Bluebrush, 40, 25);

                g.FillRectangle(Transpentbrush, 5, 287, 535, 15);



                //保存绘制的图片

                MemoryStream stream = new MemoryStream();

                img.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);



                this.pictureBox1.Image = img;

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message);

            }

        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值