zoukankan      html  css  js  c++  java
  • 无底图雷达回波生成

    最近,单位上遇到一个问题,要将本站雷达回波图动态地叠加到另一个系统上。但是,把图片直接加上且在HTML网页上设计为透明,还是存在一个阴影,因此本人用C#开发了一个无底图雷达回波处理软件。

    1、本软件需要先将黑底雷达回波图片背景变为白色,然后再将白色背景变为透明。直接调用黑色背景的雷达回波图实现不了!

    代码如下:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.IO;
    using System.Timers;
    
    namespace 透明图片
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                
    
            }
    
            private void SavePicture()
            {
                //获取日期及时间
                System.DateTime currentTime = new System.DateTime();
                currentTime = System.DateTime.Now;
                int year = currentTime.Year;
                int mounth = currentTime.Month;
                int day = currentTime.Day;
                int hour = currentTime.Hour;
                int minute = currentTime.Minute;
                int second = currentTime.Second;
    
                //以下4行代码无用
                string mon = "";
                string dayy = "";
               mon= mounth<10? "0" + mounth.ToString(): mounth.ToString();
               dayy=day<10 ? "0" + day.ToString(): day.ToString();
                
                label1.Text = string.Format("{0}年{1}月{2}日{3}时{4}分{5}秒", year, mon, dayy, hour, minute, second);
                //获取整个文件夹下路径
                string[] pathAll = Directory.GetFiles(string.Format("E:\test\Picture\{0}{1}{2}", year, mounth, dayy));
    
                //每次都新建一个文件夹,如果名字相同的,则不新建了!
                string activeDir = string.Format(@"E:	estsavPicture{0}{1}{2}", year, mon, dayy);
                string newPath = System.IO.Path.Combine(activeDir);
                System.IO.Directory.CreateDirectory(newPath);
    
                int i = 0;
                //循环遍历图片
                for (i = 0; i < pathAll.Length; i++)
                {
                    //获取文件名字
                    string fullPath = pathAll[i];//pathAll[i]="E:\test\Picture\{0}{1}{2}\xxx.png
                    string filename = System.IO.Path.GetFileName(fullPath);//文件名 “xxx.png”
    
                    Image image;
                    string path = pathAll[i];
                    image = Image.FromFile(path);
                    Bitmap bitmap = new Bitmap(image);
                    bitmap.MakeTransparent(Color.Transparent);
                    if (pathAll[i].IndexOf("雨量") > -1)//如果包含雨量
                    {
                        bitmap.Save(string.Format("E:\test\savPicture\{0}{1}{2}\{3}", year, mon, dayy, filename));
                        textBox1.AppendText(string.Format("{0}年{1}月{2}日{3}时{4}分{5}秒,雨量_{0}{1}{2}0{6}00-0{3}00.png生成成功!-----第{6}张图
    ", year, mon, dayy, hour, minute, second, i+1));
                    }
                     else
                    {
                        
    
                        bitmap.Save(string.Format("E:\test\savPicture\{0}{1}{2}\{3}", year, mon, dayy,filename));
                        textBox1.AppendText(string.Format("{0}年{1}月{2}日{3}时{4}分{5}秒,基本粒子_{0}{1}{2}{3}{4}{5}.png生成成功!-----第{6}张图
    ", year, mon, dayy, hour, minute, second, i+1));
                    }
                   
                   
                }
            }
            //添加计时器
            private void timer1_Tick(object sender, EventArgs e)
            {
                SavePicture();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                SavePicture();
               
    
            }
        }
       
        }


    没处理过的雷达图片叠加在地图上,会把方形背景也叠加上去,如图所示:

    该软件处理完毕后的无底图回波叠加上去如下图所示:

    软件运行界面如下:能每隔10分钟读取一次数据,将新的雷达回拨图片处理完毕,也可以点击“开始出图”按钮,立即处理一次。

  • 相关阅读:
    kafka副本
    kafka消息丢失
    kafka消费者
    RN8302b调试笔记
    MDK #pragma anon_unions
    [Python笔记]Strip
    [Python笔记]AnyAll
    [Python笔记]元组
    [Python笔记]列表
    嵌入式平台移植Python
  • 原文地址:https://www.cnblogs.com/xiaoyaohan/p/10155772.html
Copyright © 2011-2022 走看看