Possible bug: IRasterClassifyColorRampRenderer symbology vs break order

Discussion created by Sander77 on May 31, 2013
Hi everyone,

I've written my own code to export a ClassBreaks XML file from a classified value raster layer in ArcMap (10.1), that actually also saves the color information and not just the break values alone.

Here is the part that matters:
IRasterClassifyColorRampRenderer classifiedRenderer = (IRasterClassifyColorRampRenderer)rasterLayer.Renderer;
using (XmlWriter writer = XmlWriter.Create(xmlFile))
    for (int i = 0; i < classifiedRenderer.ClassCount; i++)
        IFillSymbol symbology = (IFillSymbol)classifiedRenderer.get_Symbol(i); <<-- This does not return the symbology that matches the same break!
        writer.WriteElementString("value", classifiedRenderer.get_Break(i + 1).ToString()); //we want the upper break value
        writer.WriteElementString("color", symbology.Color.RGB.ToString());

What actually happens, is that the symbology (or at least the color I'm trying to retrieve) has been flipped for some reason. When I ask for the first item in the renderer, I get the first break value and the LAST symbol. For the second one I get the second last symbol and so on. In my resulting XML file, I end up with the break values in the order I want, but the colors are in reverse order.

For the moment, I "fixed" this by doing something like this to get the symbol that actually belongs to the break value:
        IFillSymbol symbology = (IFillSymbol)classifiedRenderer.get_Symbol(classifiedRenderer.ClassCount - 1 - i);

But this is just weird.
Is there something wrong in my code (I certainly don't see it) or is there a bug in the IRasterClassifyColorRampRenderer interface?