Пример #1
0
        private IColorRamp CreateMultiPartColorRamp()
        {
            IMultiPartColorRamp pMultiPartColorRamp = new MultiPartColorRampClass();
            bool bture = true;

            //叠加颜色带
            pMultiPartColorRamp.AddRamp(CreateAlgorithmicColorRamp());
            pMultiPartColorRamp.AddRamp(CreateRandomColorRamp());
            //设置颜色带颜色数量
            pMultiPartColorRamp.Size = 10;
            pMultiPartColorRamp.CreateRamp(out bture);
            return(pMultiPartColorRamp);
        }
Пример #2
0
        private int[,] RedToBlueColorRamps()
        {
            IEnumColors pEnumColors = null;

            int[,] arrSepLineColor = new int[10, 3];
            IAlgorithmicColorRamp pColorRamp1 = new AlgorithmicColorRampClass();
            IAlgorithmicColorRamp pColorRamp2 = new AlgorithmicColorRampClass();

            pColorRamp1.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
            pColorRamp2.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;

            IRgbColor pColor1 = new RgbColor();
            IRgbColor pColor2 = new RgbColor();
            IRgbColor pColor3 = new RgbColor();



            pColor1 = pSnippet.getRGB(165, 0, 38);
            pColor2 = pSnippet.getRGB(255, 255, 191);
            pColor3 = pSnippet.getRGB(49, 54, 149);

            pColorRamp1.FromColor = pColor1;
            pColorRamp1.ToColor   = pColor2;
            pColorRamp2.FromColor = pColor2;
            pColorRamp2.ToColor   = pColor3;

            Boolean blnOK = true;

            IMultiPartColorRamp pMultiColorRamp = new MultiPartColorRampClass();

            pMultiColorRamp.Ramp[0] = pColorRamp1;
            pMultiColorRamp.Ramp[1] = pColorRamp2;
            pMultiColorRamp.Size    = 10;
            pMultiColorRamp.CreateRamp(out blnOK);


            pEnumColors = pMultiColorRamp.Colors;
            pEnumColors.Reset();
            for (int k = 0; k < 10; k++)
            {
                IColor    pColor    = pEnumColors.Next();
                IRgbColor pRGBColor = new RgbColorClass();
                pRGBColor.RGB = pColor.RGB;

                arrSepLineColor[k, 0] = pRGBColor.Red;
                arrSepLineColor[k, 1] = pRGBColor.Green;
                arrSepLineColor[k, 2] = pRGBColor.Blue;
            }

            return(arrSepLineColor);
        }
Пример #3
0
        public static IMultiPartColorRamp CreateMultiPartColorRamp(List <IColorRamp> lColorRamps, int iSize = 500)
        {
            IMultiPartColorRamp pMultiPartColorRamp = new MultiPartColorRampClass();

            foreach (IColorRamp pColorRamp in lColorRamps)
            {
                pMultiPartColorRamp.AddRamp(pColorRamp);
            }

            pMultiPartColorRamp.Size = iSize;
            bool bOK = true;

            pMultiPartColorRamp.CreateRamp(out bOK);
            return(pMultiPartColorRamp);
        }
        /// <summary>
        /// 打开adf文件格式栅格数据
        /// </summary>
        /// <param name="rasterPath"></param>
        /// <param name="fileName"></param>
        public static void OpenRasterLayer(string rasterPath, string fileName)
        {
            IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactory();
            IWorkspace        SWorkspace       = workspaceFactory.OpenFromFile(rasterPath, 0);
            IRasterWorkspace  rasterWorkspace  = SWorkspace as IRasterWorkspace;
            IRasterDataset    pRasterDataset   = (IRasterDataset)rasterWorkspace.OpenRasterDataset(fileName);
            IRasterLayer      pRasterLayer     = new RasterLayerClass();

            pRasterLayer.CreateFromDataset(pRasterDataset);
            IAlgorithmicColorRamp colorRamp = new AlgorithmicColorRampClass()
            {
                FromColor = new RgbColorClass()
                {
                    Red = 197, Green = 68, Blue = 56
                },
                ToColor = new RgbColorClass()
                {
                    Red = 80, Green = 110, Blue = 207
                },
                Size = 100
            };//Red = 80, Green = 110, Blue = 207
            IMultiPartColorRamp multiPartColorRamp = new MultiPartColorRampClass();

            multiPartColorRamp.set_Ramp(0, colorRamp);
            bool outCreate = false;

            colorRamp.CreateRamp(out outCreate);
            //设置渲染参数
            IRasterStretchColorRampRenderer rasterStretchColorRampRenderer = new RasterStretchColorRampRendererClass();
            IRasterRenderer rasterRenderer = rasterStretchColorRampRenderer as IRasterRenderer;

            rasterRenderer.Raster = pRasterLayer.Raster;
            rasterRenderer.Update();
            rasterStretchColorRampRenderer.BandIndex = 0;
            rasterStretchColorRampRenderer.ColorRamp = multiPartColorRamp as IColorRamp;
            rasterRenderer.Update();
            pRasterLayer.Renderer = rasterRenderer;
            MainFrom.m_mapControl.AddLayer(pRasterLayer);
        }
Пример #5
0
        private IEnumColors MultiPartColorRamp(string strColorRamp, string strAlgorithm, int intGCBreakeCount)
        {
            try
            {
                IEnumColors pEnumColors = null;

                if (strColorRamp == "Blue Light to Dark" || strColorRamp == "Green Light to Dark" || strColorRamp == "Orange Light to Dark" || strColorRamp == "Red Light to Dark")
                {
                    IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRampClass();
                    switch (strAlgorithm)
                    {
                    case "HSV":
                        pColorRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
                        break;

                    case "CIE Lab":
                        pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                        break;

                    case "Lab LCh":
                        pColorRamp.Algorithm = esriColorRampAlgorithm.esriLabLChAlgorithm;
                        break;

                    default:
                        pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                        break;
                    }

                    IRgbColor pColor1 = new RgbColor();
                    IRgbColor pColor2 = new RgbColor();

                    switch (strColorRamp)
                    {
                    case "Blue Light to Dark":
                        pColor1 = pSnippet.getRGB(239, 243, 255);
                        pColor2 = pSnippet.getRGB(8, 81, 156);
                        break;

                    case "Green Light to Dark":
                        pColor1 = pSnippet.getRGB(237, 248, 233);
                        pColor2 = pSnippet.getRGB(0, 109, 44);
                        break;

                    case "Orange Light to Dark":
                        pColor1 = pSnippet.getRGB(254, 237, 222);
                        pColor2 = pSnippet.getRGB(166, 54, 3);
                        break;

                    case "Red Light to Dark":
                        pColor1 = pSnippet.getRGB(254, 229, 217);
                        pColor2 = pSnippet.getRGB(165, 15, 21);
                        break;

                    default:
                        pColor1 = pSnippet.getRGB(254, 229, 217);
                        pColor2 = pSnippet.getRGB(165, 15, 21);
                        break;
                    }

                    Boolean blnOK = true;

                    pColorRamp.FromColor = pColor1;
                    pColorRamp.ToColor   = pColor2;
                    pColorRamp.Size      = intGCBreakeCount;
                    pColorRamp.CreateRamp(out blnOK);


                    //arrColors = new int [intGCBreakeCount,3];
                    pEnumColors = pColorRamp.Colors;
                }
                else if (strColorRamp == "Custom")
                {
                    Boolean             blnOK           = true;
                    frmColorRamps       m_pColorRamps   = System.Windows.Forms.Application.OpenForms["frmColorRamps"] as frmColorRamps;
                    IMultiPartColorRamp pMultiColorRamp = m_pColorRamps.pMulitColorRampsResults;

                    pMultiColorRamp.Size = intGCBreakeCount;
                    pMultiColorRamp.CreateRamp(out blnOK);


                    pEnumColors = pMultiColorRamp.Colors;
                }
                else
                {
                    IAlgorithmicColorRamp pColorRamp1 = new AlgorithmicColorRampClass();
                    IAlgorithmicColorRamp pColorRamp2 = new AlgorithmicColorRampClass();


                    switch (strAlgorithm)
                    {
                    case "HSV":
                        pColorRamp1.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
                        pColorRamp2.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;
                        break;

                    case "CIE Lab":
                        pColorRamp1.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                        pColorRamp2.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                        break;

                    case "Lab LCh":
                        pColorRamp1.Algorithm = esriColorRampAlgorithm.esriLabLChAlgorithm;
                        pColorRamp2.Algorithm = esriColorRampAlgorithm.esriLabLChAlgorithm;
                        break;

                    default:
                        pColorRamp1.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                        pColorRamp2.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                        break;
                    }

                    IRgbColor pColor1 = new RgbColor();
                    IRgbColor pColor2 = new RgbColor();
                    IRgbColor pColor3 = new RgbColor();

                    switch (strColorRamp)
                    {
                    case "Blue to Red":
                        pColor1 = pSnippet.getRGB(49, 54, 149);
                        pColor2 = pSnippet.getRGB(255, 255, 191);
                        pColor3 = pSnippet.getRGB(165, 0, 38);
                        break;

                    case "Green to Purple":
                        pColor1 = pSnippet.getRGB(0, 68, 27);
                        pColor2 = pSnippet.getRGB(247, 247, 247);
                        pColor3 = pSnippet.getRGB(64, 0, 75);
                        break;

                    case "Green to Red":
                        pColor1 = pSnippet.getRGB(0, 104, 55);
                        pColor2 = pSnippet.getRGB(255, 255, 191);
                        pColor3 = pSnippet.getRGB(165, 0, 38);
                        break;

                    case "Purple to Brown":
                        pColor1 = pSnippet.getRGB(45, 0, 75);
                        pColor2 = pSnippet.getRGB(247, 247, 247);
                        pColor3 = pSnippet.getRGB(127, 59, 8);
                        break;

                    default:
                        pColor1 = pSnippet.getRGB(49, 54, 149);
                        pColor2 = pSnippet.getRGB(255, 255, 191);
                        pColor3 = pSnippet.getRGB(165, 0, 38);
                        break;
                    }


                    pColorRamp1.FromColor = pColor1;
                    pColorRamp1.ToColor   = pColor2;
                    pColorRamp2.FromColor = pColor2;
                    pColorRamp2.ToColor   = pColor3;

                    Boolean blnOK = true;

                    IMultiPartColorRamp pMultiColorRamp = new MultiPartColorRampClass();
                    pMultiColorRamp.Ramp[0] = pColorRamp1;
                    pMultiColorRamp.Ramp[1] = pColorRamp2;
                    pMultiColorRamp.Size    = intGCBreakeCount;
                    pMultiColorRamp.CreateRamp(out blnOK);


                    pEnumColors = pMultiColorRamp.Colors;
                }
                pEnumColors.Reset();
                return(pEnumColors);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this.Handle.ToString() + " Error:" + ex.Message);
                return(null);
            }
        }
Пример #6
0
        private IEnumColors MultiPartColorRamp(string strColorRamp, int intGCBreakeCount)
        {
            IAlgorithmicColorRamp pColorRamp1 = new AlgorithmicColorRampClass();

            pColorRamp1.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
            IAlgorithmicColorRamp pColorRamp2 = new AlgorithmicColorRampClass();

            pColorRamp2.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;

            IRgbColor pColor1 = new RgbColor();
            IRgbColor pColor2 = new RgbColor();
            IRgbColor pColor3 = new RgbColor();

            switch (strColorRamp)
            {
            case "Blue to Red":
                pColor1 = pSnippet.getRGB(49, 54, 149);
                pColor2 = pSnippet.getRGB(255, 255, 191);
                pColor3 = pSnippet.getRGB(165, 0, 38);
                break;

            case "Green to Purple":
                pColor1 = pSnippet.getRGB(0, 68, 27);
                pColor2 = pSnippet.getRGB(247, 247, 247);
                pColor3 = pSnippet.getRGB(64, 0, 75);
                break;

            case "Green to Red":
                pColor1 = pSnippet.getRGB(0, 104, 55);
                pColor2 = pSnippet.getRGB(255, 255, 191);
                pColor3 = pSnippet.getRGB(165, 0, 38);
                break;

            case "Purple to Brown":
                pColor1 = pSnippet.getRGB(45, 0, 75);
                pColor2 = pSnippet.getRGB(247, 247, 247);
                pColor3 = pSnippet.getRGB(127, 59, 8);
                break;

            default:
                pColor1 = pSnippet.getRGB(49, 54, 149);
                pColor2 = pSnippet.getRGB(255, 255, 191);
                pColor3 = pSnippet.getRGB(165, 0, 38);
                break;
            }


            pColorRamp1.FromColor = pColor1;
            pColorRamp1.ToColor   = pColor2;
            pColorRamp2.FromColor = pColor2;
            pColorRamp2.ToColor   = pColor3;

            Boolean blnOK = true;

            IMultiPartColorRamp pMultiColorRamp = new MultiPartColorRampClass();

            pMultiColorRamp.Ramp[0] = pColorRamp1;
            pMultiColorRamp.Ramp[1] = pColorRamp2;
            pMultiColorRamp.Size    = intGCBreakeCount;
            pMultiColorRamp.CreateRamp(out blnOK);


            IEnumColors pEnumColors = pMultiColorRamp.Colors;

            return(pEnumColors);
        }