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]; CorrectLabOutofRange(ref iLabOut[0], ref iLabOut[1], ref iLabOut[2]); IHsvColor pHSVColor = null; pHSVColor = new HsvColor(); pHSVColor.SetCIELAB(iLabOut[0], iLabOut[1], iLabOut[2]); pOutColor = pHSVColor; } return pOutColor; }