当前位置: 首页>>代码示例>>C#>>正文


C# IColor.GetCIELAB方法代码示例

本文整理汇总了C#中IColor.GetCIELAB方法的典型用法代码示例。如果您正苦于以下问题:C# IColor.GetCIELAB方法的具体用法?C# IColor.GetCIELAB怎么用?C# IColor.GetCIELAB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IColor的用法示例。


在下文中一共展示了IColor.GetCIELAB方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCombinedColor

		private ESRI.ArcGIS.Display.IColor GetCombinedColor(IColor pColor1, IColor pColor2, EColorCombinationType eCombinationMethod, IColor pOriginColor)
		{
			// combines the input colors based on m_eColorCombinationMethod

			// (11/08/04) -- RGB and enuLabLChColorRamp aren't used by GUI

			IColor pOutColor = null;

			long MyOLE_COLOR = 0; // As OLE_COLOR in VB6
			IRgbColor pMainRGBColor = null;
			IRgbColor pVariationRGBColor = null;
			IRgbColor pMergedRGBColor = null;
			bool bOK = false;
			IAlgorithmicColorRamp pAlgorithmicCR = null;

			// if either of the colors are null, then don't run the color through any algorithm,
			//   instead, just return the other color.  if both are null, then return a null color
			if (pColor1.NullColor)
			{
				pOutColor = pColor2;

			}
			else if (pColor2.NullColor)
			{
				pOutColor = pColor1;

			}
			else if (eCombinationMethod == EColorCombinationType.enuComponents)
			{
				// HSV components
				// create a new HSV color
				IHsvColor pHSVDrawColor = null;
				pHSVDrawColor = new HsvColor();
				// get HSV values from Color1 and Color2 and assign to pHSVDrawColor
				IHsvColor pHSVColor1 = null;
				IHsvColor pHSVColor2 = null;

				// (new 4/27/04) didn't think I had to do this...
				//pHSVColor1 = pColor1
				//pHSVColor2 = pColor2
				pHSVColor1 = new HsvColor();
				pHSVColor1.RGB = pColor1.RGB;
				pHSVColor2 = new HsvColor();
				pHSVColor2.RGB = pColor2.RGB;

				pHSVDrawColor.Hue = pHSVColor1.Hue;
				pHSVDrawColor.Saturation = pHSVColor2.Saturation;
				pHSVDrawColor.Value = pHSVColor2.Value;

				pOutColor = pHSVDrawColor;

			}
			else if (eCombinationMethod == EColorCombinationType.enuRGBAverage)
			{
				// use additive color model to merge the two colors
				MyOLE_COLOR = pColor1.RGB;
				pMainRGBColor = new RgbColor();
				pMainRGBColor.RGB = (int)MyOLE_COLOR;
				MyOLE_COLOR = pColor2.RGB;
				pVariationRGBColor = new RgbColor();
				pVariationRGBColor.RGB = (int)MyOLE_COLOR;
				// merged color = RGB average of the two colors
				pMergedRGBColor = new RgbColor();
				pMergedRGBColor.Red = (pMainRGBColor.Red + pVariationRGBColor.Red) / 2;
				pMergedRGBColor.Green = (pMainRGBColor.Green + pVariationRGBColor.Green) / 2;
				pMergedRGBColor.Blue = (pMainRGBColor.Blue + pVariationRGBColor.Blue) / 2;

				pOutColor = pMergedRGBColor;
			}
			else if ((eCombinationMethod == EColorCombinationType.enuCIELabColorRamp) | (eCombinationMethod == EColorCombinationType.enuLabLChColorRamp))
			{
				// use color ramp and take central color between the two colors
				pAlgorithmicCR = new AlgorithmicColorRamp();
				if (m_eColorCombinationMethod == EColorCombinationType.enuCIELabColorRamp)
					pAlgorithmicCR.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
				else
					pAlgorithmicCR.Algorithm = esriColorRampAlgorithm.esriLabLChAlgorithm;
				pAlgorithmicCR.Size = 3;
				pAlgorithmicCR.FromColor = pColor1;
				pAlgorithmicCR.ToColor = pColor2;
				pAlgorithmicCR.CreateRamp(out bOK);

				pOutColor = pAlgorithmicCR.get_Color(1); // middle color in ramp
			}
			else // EColorCombinationType.enuCIELabMatrix
			{

				double[] iLab1 = new double[4]; // L, a, b values for Color1
				double[] iLab2 = new double[4]; // L, a, b values for Color2
				double[] iLabOrig = new double[4]; // L, a, b values for pOriginColor
				pColor1.GetCIELAB(out iLab1[0], out iLab1[1], out iLab1[2]);
				pColor2.GetCIELAB(out iLab2[0], out iLab2[1], out iLab2[2]);
				pOriginColor.GetCIELAB(out iLabOrig[0], out iLabOrig[1], out iLabOrig[2]);

				double[] iLabOut = new double[4];
				// add color1 vector and color2 vector, then subtract the origin color vector
				iLabOut[0] = iLab1[0] + iLab2[0] - iLabOrig[0];
				iLabOut[1] = iLab1[1] + iLab2[1] - iLabOrig[1];
				iLabOut[2] = iLab1[2] + iLab2[2] - iLabOrig[2];

//.........这里部分代码省略.........
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:101,代码来源:MultivariateRenderer.cs


注:本文中的IColor.GetCIELAB方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。