public void Bind(object pArgument)
 {
     if (pArgument is mosaicFunctionArguments)
     {
         mosaicFunctionArguments arg = (mosaicFunctionArguments)pArgument;
         inrs = arg.InRasterArr;
         outrs = arg.OutRaster;
         //Console.WriteLine("Number of Bands in outrs = " + ((IRasterBandCollection)outrs).Count.ToString());
         mos = arg.Mosaic;
         IRasterProps rsProp = (IRasterProps)outrs;
         myFunctionHelper.Bind(outrs);
         myRasterInfo = myFunctionHelper.RasterInfo;
         myPixeltype = myRasterInfo.PixelType;
         myValidFlag = true;
     }
     else
     {
         throw new System.Exception("Incorrect arguments object. Expected: mergeFunctionArguments");
     }
 }
示例#2
0
 public void Bind(object pArgument)
 {
     if (pArgument is mosaicFunctionArguments)
     {
         mosaicFunctionArguments arg = (mosaicFunctionArguments)pArgument;
         inrs  = arg.InRasterArr;
         outrs = arg.OutRaster;
         //Console.WriteLine("Number of Bands in outrs = " + ((IRasterBandCollection)outrs).Count.ToString());
         mos = arg.Mosaic;
         IRasterProps rsProp = (IRasterProps)outrs;
         myFunctionHelper.Bind(outrs);
         myRasterInfo = myFunctionHelper.RasterInfo;
         myPixeltype  = myRasterInfo.PixelType;
         myValidFlag  = true;
     }
     else
     {
         throw new System.Exception("Incorrect arguments object. Expected: mergeFunctionArguments");
     }
 }
示例#3
0
        private void buttonX_ok_Click(object sender, EventArgs e)
        {
            try
            {
                IRasterCollection pRasterCollection = new MosaicRasterClass();
                for (int i = 0; i < listBox1.Items.Count; i++)
                {
                    IRasterLayer prasterlayer = new RasterLayerClass();
                    prasterlayer.CreateFromFilePath(listBox1.Items[i].ToString());
                    pRasterCollection.Append(prasterlayer.Raster);
                }
                IMosaicRaster pMosaicRaster = pRasterCollection as IMosaicRaster;
                switch (cmbox_operatortype.SelectedIndex)
                {
                case 0:
                    pMosaicRaster.MosaicOperatorType = rstMosaicOperatorType.MT_FIRST;
                    break;

                case 1:
                    pMosaicRaster.MosaicOperatorType = rstMosaicOperatorType.MT_LAST;
                    break;

                case 2:
                    pMosaicRaster.MosaicOperatorType = rstMosaicOperatorType.MT_MIN;
                    break;

                case 3:
                    pMosaicRaster.MosaicOperatorType = rstMosaicOperatorType.MT_MAX;
                    break;

                case 4:
                    pMosaicRaster.MosaicOperatorType = rstMosaicOperatorType.MT_MEAN;
                    break;

                case 5:
                    pMosaicRaster.MosaicOperatorType = rstMosaicOperatorType.MT_BLEND;
                    break;

                default:
                    pMosaicRaster.MosaicOperatorType = rstMosaicOperatorType.MT_LAST;
                    break;
                }
                switch (comboBox_colormap.SelectedIndex)
                {
                case 0:
                    pMosaicRaster.MosaicColormapMode = rstMosaicColormapMode.MM_FIRST;
                    break;

                case 1:
                    pMosaicRaster.MosaicColormapMode = rstMosaicColormapMode.MM_LAST;
                    break;

                case 2:
                    pMosaicRaster.MosaicColormapMode = rstMosaicColormapMode.MM_MATCH;
                    break;

                case 3:
                    pMosaicRaster.MosaicColormapMode = rstMosaicColormapMode.MM_REJECT;
                    break;

                default:
                    pMosaicRaster.MosaicColormapMode = rstMosaicColormapMode.MM_FIRST;
                    break;
                }
                if (string.IsNullOrEmpty(textBoxX_output.Text) == true)
                {
                    return;
                }
                //如果直接保存为img影像文件
                IWorkspaceFactory pWKSF      = new RasterWorkspaceFactoryClass();
                IWorkspace        pWorkspace = pWKSF.OpenFromFile(System.IO.Path.GetDirectoryName(textBoxX_output.Text), 0);
                ISaveAs           pSaveAs    = pMosaicRaster as ISaveAs;
                IDataset          pDataset   = pSaveAs.SaveAs(System.IO.Path.GetFileNameWithoutExtension(textBoxX_output.Text) + ".tif", pWorkspace, "TIFF");//以TIF格式保存
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pDataset);
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }