Пример #1
0
        /// <summary>
        ///  树视图点击捕捉,用于邮件弹出功能栏
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Map_treeView_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = sender as ToolStripMenuItem;
            Bitmap2           bmp2 = _imageDic[map_treeView.SelectedNode.Text];

            switch (item.Name)
            {
            case "bandCombine_ToolStripMenuItem":
                BandForm bandModal = new BandForm
                {
                    GdalLayer = bmp2.GdalLayer
                };
                if (bandModal.ShowDialog() == DialogResult.OK)
                {
                    List <int> combineIndex = bandModal.BanCombineIndex;
                    Bitmap     layerBitmap  = GRGBCombine.Run(
                        bandModal.GdalLayer.BandCollection[combineIndex[0]].GetByteData(),
                        bandModal.GdalLayer.BandCollection[combineIndex[1]].GetByteData(),
                        bandModal.GdalLayer.BandCollection[combineIndex[2]].GetByteData());
                    Bitmap2 layerBitmap2 = new Bitmap2(bmp: layerBitmap, name: bandModal.GdalLayer.Name, gdalLayer: bandModal.GdalLayer);
                    //获取band对应的bitmap格式图像,载入treedNode中
                    _imageDic[bandModal.GdalLayer.Name] = layerBitmap2;
                    map_pictureBox.Image = layerBitmap2.BMP;
                }
                break;

            default:
                break;
            }
        }
        private void PaintBar(IGraphics g, int scrollBarWid, int height)
        {
            if (!HasBar)
            {
                return;
            }
            if (bar != null && CalcBarSize(height) != bar.Height)
            {
                bar = null;
            }
            if (bar == null)
            {
                CreateBar(scrollBarWid, height);
            }
            int h = CalcBarStart(height);

            switch (state)
            {
            case ScrollBarState.HighlightBar:
                g.DrawImageUnscaled(barHighlight, 1, h);
                break;

            case ScrollBarState.PressBar:
                g.DrawImageUnscaled(barPress, 1, h);
                break;

            default:
                g.DrawImageUnscaled(bar, 1, h);
                break;
            }
        }
Пример #3
0
        public static Bitmap2 ReadImage(string filePath)
        {
            BinaryReader reader = FileUtils.GetBinaryReader(filePath);
            Bitmap2      bm     = ReadImage(reader.BaseStream);

            reader.Close();
            return(bm);
        }
Пример #4
0
 public void DrawImageUnscaled(Bitmap2 image, float x, float y)
 {
     // TODO reduce the resolution to fit (?)
     try {
         Image img = Image.GetInstance(GraphUtils.ToBitmap(image), System.Drawing.Imaging.ImageFormat.Tiff);
         img.SetAbsolutePosition(x, currentHeight - img.ScaledHeight - y);
         template.AddImage(img);
     } catch { }
 }
Пример #5
0
        public ParameterForm(Parameters parameters, string title, string helpDescription, string helpOutput,
                             IList <string> helpSuppls, Action helpAction)
        {
            InitializeComponent();
            this.helpAction = helpAction;
            if (helpAction == null)
            {
                helpButton1.Width = 0;
                helpButton2.Width = 0;
            }
            okButton1.Click     += OkButtonClick;
            okButton2.Click     += OkButtonClick;
            cancelButton1.Click += CancelButtonClick;
            cancelButton2.Click += CancelButtonClick;
            helpButton1.Click   += HelpButtonClick;
            helpButton2.Click   += HelpButtonClick;
            Bitmap bm = new Bitmap(GraphUtils.ToBitmap(Bitmap2.GetImage("help.png")), 18, 18);

            helpButton1.Image = bm;
            helpButton2.Image = bm;
            KeyDown          += OnKeyDownHandler;
            Height            = (int)(parameterPanel1.Init(parameters) + 65);
            helpPanel1.Controls.Clear();
            helpPanel2.Controls.Clear();
            List <string> titles      = new List <string>();
            List <string> description = new List <string>();

            if (!string.IsNullOrEmpty(helpDescription))
            {
                titles.Add("Description");
                description.Add(helpDescription);
            }
            if (!string.IsNullOrEmpty(helpOutput))
            {
                titles.Add(" - ");
                description.Add(null);
                titles.Add("Output");
                description.Add(helpOutput);
            }
            if (helpSuppls != null)
            {
                for (int i = 0; i < helpSuppls.Count; i++)
                {
                    if (!string.IsNullOrEmpty(helpSuppls[i]))
                    {
                        titles.Add(" - ");
                        description.Add(null);
                        titles.Add("Suppl. table " + (i + 1));
                        description.Add(helpSuppls[i]);
                    }
                }
            }
            AddHelp(titles, description, title, helpPanel1);
            AddHelp(titles, description, title, helpPanel2);
        }
Пример #6
0
        private void CreateSecondMark(int scrollBarWid)
        {
            int     w = scrollBarWid - 1;
            int     h = scrollBarWid - 2;
            Bitmap2 b = new Bitmap2(w, h);

            GraphUtil.FillShadedRectangle(b, w, h);
            secondMark          = b;
            secondMarkHighlight = b.Lighter();
            secondMarkPress     = b.Darker();
        }
Пример #7
0
        private void CreateBar(int scrollBarWid, int width)
        {
            int     w = CalcBarSize(width);
            int     h = scrollBarWid - 2;
            Bitmap2 b = new Bitmap2(w, h);

            GraphUtil.FillShadedRectangle(b, w, h);
            bar          = b;
            barHighlight = b.Lighter();
            barPress     = b.Darker();
        }
Пример #8
0
 public FilterForm(SubSelectionControl subSelectionControl)
 {
     InitializeComponent();
     this.subSelectionControl = subSelectionControl;
     addButton.Image          = GraphUtils.ToBitmap(Bitmap2.GetImage("plus1.bmp"));
     removeButton.Image       = GraphUtils.ToBitmap(Bitmap2.GetImage("minus1.bmp"));
     //Icon = GraphUtils.ToBitmap(Bitmap2.GetImage("Perseus.jpg"));
     addButton.Click    += AddButton_OnClick;
     removeButton.Click += RemoveButton_OnClick;
     RebuildGui();
 }
Пример #9
0
        /// <summary>
        ///  树视图点击捕捉,用于邮件弹出功能栏
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Map_treeView_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = sender as ToolStripMenuItem;
            Bitmap2           bmp2 = _imageDic[map_treeView.SelectedNode.Text];

            switch (item.Name)
            {
            case "bandExport_ToolStripMenuItem":
                if (bmp2.GdalBand == null)
                {
                    return;
                }
                BandExportForm bandExportModel = new BandExportForm()
                {
                    RasterLayer = bmp2.GdalLayer,
                    RasterDic   = _rasterDic,
                    Index       = bmp2.GdalBand.Index - 1
                };
                if (bandExportModel.ShowDialog() == DialogResult.OK)
                {
                    if (!bandExportModel.HasChecked)
                    {
                        return;
                    }
                    bandExportModel.Save();
                    MessageBox.Show("导出成功", "结果", MessageBoxButtons.OK, icon: MessageBoxIcon.Information);
                }
                break;

            case "bandCombine_ToolStripMenuItem":
                BandForm bandModal = new BandForm
                {
                    GdalLayer = bmp2.GdalLayer
                };
                if (bandModal.ShowDialog() == DialogResult.OK)
                {
                    List <int> combineIndex = bandModal.BanCombineIndex;
                    Bitmap     layerBitmap  = GRGBCombine.Run(
                        bandModal.GdalLayer.BandCollection[combineIndex[0]].GetByteBuffer(),
                        bandModal.GdalLayer.BandCollection[combineIndex[1]].GetByteBuffer(),
                        bandModal.GdalLayer.BandCollection[combineIndex[2]].GetByteBuffer());
                    Bitmap2 layerBitmap2 = new Bitmap2(bmp: layerBitmap, name: bandModal.GdalLayer.Name, gdalLayer: bandModal.GdalLayer);
                    //获取band对应的bitmap格式图像,载入treedNode中
                    _imageDic[bandModal.GdalLayer.Name] = layerBitmap2;
                    map_pictureBox.Image = layerBitmap2.BMP;
                }
                break;

            default:
                break;
            }
        }
        private void CreateFirstMark(int scrollBarWid)
        {
            int     w = scrollBarWid - 2;
            int     h = scrollBarWid - 1;
            Bitmap2 b = new Bitmap2(w, h);

            GraphUtil.FillShadedRectangle(b, w, h);
            Bitmap2 bh = b.Lighter();
            Bitmap2 bp = b.Darker();

            firstMark          = b;
            firstMarkHighlight = bh;
            firstMarkPress     = bp;
        }
        public static Bitmap2 GetImage(string file)
        {
            Assembly thisExe = Assembly.GetExecutingAssembly();
            Stream   file1   = thisExe.GetManifestResourceStream("PerseusPluginLib.img." + file);

            if (file1 == null)
            {
                return(null);
            }
            Bitmap2 bm = Image2.ReadImage(file1);

            file1.Close();
            return(bm);
        }
Пример #12
0
 /// <summary>
 /// 树视图结点操作
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Map_treeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     //左键,选择图像显示
     if (e.Button == MouseButtons.Left)
     {
         map_treeView.SelectedNode = e.Node;
         _selectBmp2          = _imageDic[e.Node.Text];
         map_pictureBox.Image = _selectBmp2?.BMP;
     }
     else if (e.Button == MouseButtons.Right)
     {
         map_treeView.SelectedNode = e.Node;
         tree_contextMenuStrip.Show(map_treeView, new Point(e.X, e.Y));
     }
 }
Пример #13
0
        public void DrawImage(Bitmap2 image, float x, float y, float width, float height)
        {
            Image img = null;

            try {
                img = Image.GetInstance(GraphUtils.ToBitmap(image), System.Drawing.Imaging.ImageFormat.Tiff);
            } catch (Exception ex) {
                Console.Error.WriteLine(ex.Message);
            }
            if (img != null)
            {
                img.ScaleAbsolute(width, height);
                img.SetAbsolutePosition(x, currentHeight - img.ScaledHeight - y);
                template.AddImage(img);
            }
        }
Пример #14
0
        //from perseus-plugins/PerseusPluginLib/Utils/PerseusPluginUtils.cs
        public static Bitmap2 GetImage(string file)
        {
            //remember to change the image files Build Action to Embedded Resource
            Assembly thisExe = Assembly.GetExecutingAssembly();
            //path is default namespace + folder, where each is separated by '.'
            Stream file1 = thisExe.GetManifestResourceStream("PluginPECA.Resources." + file);

            if (file1 == null)
            {
                return(null);
            }
            Bitmap2 bm = Image2.ReadImage(file1);

            file1.Close();
            return(bm);
        }
Пример #15
0
        /// <summary>
        /// 波段读取
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="parentNode"></param>
        private void ReadBand(string rasterFilename, TreeNode parentNode)
        {
            string       name   = parentNode.Text;
            GRasterLayer _layer = new GRasterLayer(rasterFilename);

            for (int i = 0; i < _layer.BandCollection.Count; i++)
            {
                IGBand band = _layer.BandCollection[i];
                band.BandName = name + "_波段_" + i;
                Bitmap2 bmp2 = new Bitmap2(bmp: band.GetBitmap(), name: band.BandName, gdalBand: band, gdalLayer: _layer);
                //获取band对应的bitmap格式图像,载入treedNode中
                _imageDic.Add(band.BandName, bmp2);
                TreeNode childrenNode = new TreeNode(band.BandName);
                Invoke(new UpdateTreeNodeHandler(UpdateTreeNode), parentNode, childrenNode);
            }
        }
Пример #16
0
        public static Bitmap ToBitmap(Bitmap2 bitmap)
        {
            if (bitmap == null)
            {
                return(null);
            }
            Bitmap result = new Bitmap(bitmap.Width, bitmap.Height);

            for (int i = 0; i < bitmap.Width; i++)
            {
                for (int j = 0; j < bitmap.Height; j++)
                {
                    result.SetPixel(i, j, Color.FromArgb(bitmap.GetPixel(i, j)));
                }
            }
            return(result);
        }
Пример #17
0
        public static Bitmap2 ToBitmap2(Bitmap bitmap)
        {
            if (bitmap == null)
            {
                return(null);
            }
            Bitmap2 result = new Bitmap2(bitmap.Width, bitmap.Height);

            for (int i = 0; i < bitmap.Width; i++)
            {
                for (int j = 0; j < bitmap.Height; j++)
                {
                    result.SetPixel(i, j, bitmap.GetPixel(i, j).ToArgb());
                }
            }
            return(result);
        }
Пример #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="fullFilename"></param>
 public JobReadRaster(string fullFilename)
 {
     _t = new Thread(() =>
     {
         Dictionary <string, Bitmap2> dict = new Dictionary <string, Bitmap2>();
         string name = Path.GetFileNameWithoutExtension(fullFilename);
         GRasterLayer rasterLayer = new GRasterLayer(fullFilename);
         //reading
         Summary = "数据读取中";
         for (int i = 0; i < rasterLayer.BandCount; i++)
         {
             GRasterBand band    = rasterLayer.BandCollection[i];
             band.BandName       = name + "_band_" + i;
             Bitmap2 bmp2        = new Bitmap2(bmp: band.GrayscaleImage, name: band.BandName, gdalBand: band, gdalLayer: rasterLayer);
             dict[band.BandName] = bmp2;
             Process             = (double)(i + 1) / rasterLayer.BandCount;
         }
         //read complete
         Summary  = "读取完毕";
         Complete = true;
         OnTaskComplete?.Invoke(Name, name, dict, rasterLayer);
     });
 }
Пример #19
0
 public void DrawImageUnscaled(Bitmap2 image, float x, float y)
 {
     throw new System.NotImplementedException();
 }
Пример #20
0
        public ParameterForm(Parameters parameters, string title, string helpDescription, string helpOutput,
                             IList <string> helpSuppls, Action helpAction)
        {
            InitializeComponent();
            this.helpAction = helpAction;
            if (helpAction == null)
            {
                helpButton.Width = 0;
            }
            okButton.Click     += OkButtonClick;
            cancelButton.Click += CancelButtonClick;
            helpButton.Click   += HelpButtonClick;
            helpButton.Image    = new Bitmap(GraphUtils.ToBitmap(Bitmap2.GetImage("help.png")), 18, 18);
            KeyDown            += OnKeyDownHandler;
            Height              = (int)(parameterPanel1.Init(parameters) + 65);
            helpPanel.Controls.Clear();
            List <string> titles      = new List <string>();
            List <string> description = new List <string>();

            if (!string.IsNullOrEmpty(helpDescription))
            {
                titles.Add("Description");
                description.Add(helpDescription);
            }
            if (!string.IsNullOrEmpty(helpOutput))
            {
                titles.Add(" - ");
                description.Add(null);
                titles.Add("Output");
                description.Add(helpOutput);
            }
            if (helpSuppls != null)
            {
                for (int i = 0; i < helpSuppls.Count; i++)
                {
                    if (!string.IsNullOrEmpty(helpSuppls[i]))
                    {
                        titles.Add(" - ");
                        description.Add(null);
                        titles.Add("Suppl. table " + (i + 1));
                        description.Add(helpSuppls[i]);
                    }
                }
            }
            TableLayoutPanel g = new TableLayoutPanel();

            g.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50));
            for (int i = 0; i < titles.Count; i++)
            {
                g.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 50));
            }
            g.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50));
            for (int i = 0; i < titles.Count; i++)
            {
                Label tb = new Label {
                    Text = titles[i]
                };
                //ToolTipService.SetShowDuration(tb, 400000);
                //if (description[i] != null){
                //	tb.ToolTip = new ToolTip{
                //		Content = StringUtils.Concat("\n", StringUtils.Wrap(description[i], 75))
                //	};
                //}
                g.Controls.Add(tb, i + 1, 0);
            }
            helpPanel.Controls.Add(g);
            Text = title;
        }
Пример #21
0
 public void DrawImageUnscaled(Bitmap2 image, float x, float y)
 {
     gc.DrawImageUnscaled(GraphUtils.ToBitmap(image), (int)x, (int)y);
 }
Пример #22
0
 public void DrawImage(Bitmap2 image, float x, float y, float width, float height)
 {
     g.DrawImage(image, s * x, s * y, s * width, s * height);
 }
Пример #23
0
        /// <summary>
        /// 底图区域功能按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Map_function_Click(object sender, EventArgs e)
        {
            ToolStripItem item = sender as ToolStripItem;

            switch (item.Name)
            {
            case "Export_Bitmap_ToolStripMenuItem":
                Bitmap saveBmp = map_pictureBox.Image as Bitmap;
                SaveBitmap(saveBmp);
                //导出图片
                break;

            case "DL_CLASS_toolStripButton":
                if (map_treeView.SelectedNode == null)
                {
                    UpdateStatusLabel("请选择一副图像或者一个图层后,进行分类操作", STATUE_ENUM.ERROR);
                    return;
                }
                else
                {
                    DLClassifyForm dlclassify = new DLClassifyForm();
                    if (dlclassify.ShowDialog() == DialogResult.OK)
                    {
                        //1.选择处理那副图像
                        string       imageName    = map_treeView.SelectedNode.Text;
                        Bitmap2      imageBitmap2 = _imageDic[imageName];
                        GRasterLayer rasterLayer  = imageBitmap2.GdalLayer;
                        ThreadStart  clsfy_ts     = delegate { RunClassify(rasterLayer, dlclassify.UseSLIC, dlclassify.PBName, dlclassify.CenterName, dlclassify.LabelName); };
                        Thread       clsfy_t      = new Thread(clsfy_ts);
                        clsfy_t.IsBackground = true;
                        clsfy_t.Start();
                    }
                }
                break;

            case "open_toolstripmenuitem":    //添加图像
                ReadImage();
                break;

            case "open_contextMenuStrip":
                ReadImage();
                break;

            //超像素分割
            case "SLIC_toolStripButton":
            case "SLIC_toolStripMenu":
                Bitmap bmp = map_pictureBox.Image as Bitmap;
                if (bmp != null)
                {
                    ThreadStart slic_ts = delegate { RunSLIC(bmp); };
                    Thread      slic_t  = new Thread(slic_ts);
                    slic_t.IsBackground = true;
                    slic_t.Start();
                }
                else
                {
                    UpdateStatusLabel("未选中待计算图像,地图区域无图片", STATUE_ENUM.ERROR);
                }
                break;

            //超像素中心应用
            case "SLIC_Center_toolStripButton":
            case "SLIC_Center_toolStripMenu":
                OpenFileDialog opg = new OpenFileDialog
                {
                    Filter = "JSON文件|*.json"
                };
                if (opg.ShowDialog() == DialogResult.OK)
                {
                    //1.读取center中心
                    using (StreamReader sr = new StreamReader(opg.FileName))
                    {
                        List <byte> colors  = new List <byte>();
                        Center[]    centers = SuperPixelSegment.ReadCenter(sr.ReadToEnd());
                        //2.设置使用图层
                        CenterApplyForm centerApplyForm = new CenterApplyForm();
                        if (centerApplyForm.ShowDialog() == DialogResult.OK)
                        {
                            ThreadStart s = delegate { RunCenter(centerApplyForm.FileNameCollection, centers); };
                            Thread      t = new Thread(s)
                            {
                                IsBackground = true
                            };
                            t.Start();
                        }
                    }
                }
                break;

            default:
                break;
            }
        }
Пример #24
0
 public void DrawImageUnscaled(Bitmap2 image, float x, float y)
 {
     g.DrawImageUnscaled(image, s * x, s * y);
 }
 public void InvalidateOverview()
 {
     overviewBitmap = null;
 }
 public override void OnResize(EventArgs e, int width, int height)
 {
     bar = null;
 }
Пример #27
0
 /// <summary>
 /// Draws the specified Image at the specified location and with the specified size.
 /// </summary>
 /// <param name="image">Image to draw.</param>
 /// <param name="x">The x-coordinate of the upper-left corner of the drawn image.</param>
 /// <param name="y">The y-coordinate of the upper-left corner of the drawn image.</param>
 /// <param name="width">Width of the drawn image.</param>
 /// <param name="height">Height of the drawn image.</param>
 public void DrawImage(Bitmap2 image, float x, float y, float width, float height)
 {
     imageList.Add(new SvgImage {
         X = x, Y = y, Transform = Transform
     });
 }
Пример #28
0
 /// <summary>
 /// Draws the specified image using its original physical size at the location specified by a coordinate pair.
 /// </summary>
 /// <param name="image">Image to draw.</param>
 /// <param name="x">The x-coordinate of the upper-left corner of the drawn image.</param>
 /// <param name="y">The y-coordinate of the upper-left corner of the drawn image.</param>
 public void DrawImageUnscaled(Bitmap2 image, float x, float y)
 {
     imageList.Add(new SvgImage {
         X = x, Y = y, Transform = Transform
     });
 }
Пример #29
0
 public Bitmap2Graphics(int width, int height)
 {
     Bitmap = new Bitmap2(width, height);
 }
Пример #30
0
 public void DrawImageUnscaled(Bitmap2 image, float x, float y)
 {
     throw new System.NotImplementedException();
 }
Пример #31
0
 public void DrawImage(Bitmap2 image, float x, float y, float width, float height)
 {
     throw new System.NotImplementedException();
 }
Пример #32
0
 public void DrawImage(Bitmap2 image, float x, float y, float width, float height)
 {
     throw new System.NotImplementedException();
 }
Пример #33
0
 public Bitmap2Graphics(int width, int height)
 {
     Bitmap = new Bitmap2(width, height);
 }