GetTextBackGroundColor outputs wrong colors? Answered

Hey, I am working with tables and I am using the mentioned method to check for the TextColor. I use the FromArgb method of the Color-object to convert the value into a Color object.

int textColor;  
int backColor;  
image.GetTextBackgroundColor(tableCell.Left, tableCell.Top, tableCell.Right, tableCell.Bottom, 0, out textColor, out backColor);  
Color tc = Color.FromArgb(textColor);  
Color bc = Color.FromArgb(backColor);

When I check the RGB values of tc, I get the values 70,70,115 for (slightly) red text color. The values indicate a blue color. For blue text it is the other way around.
In case I made a mistake in the way I output the color... here is my output.

Console.WriteLine(String.Format("Cell{0} contains text color: ({1},{2},{3}) background: ({4},{5},{6})", i, tc.R, tc.G, tc.B, bc.R, bc.G, bc.B));

There is no problem in fixing this but I was wondering if you calculate the int for the color differently than the standard AARRGGBB.




  • Avatar
    Anna Savinova

    This situation, not #AARRGGBB, but #RRGGBB model is used. Here is the Help quote: "The int value is calculated from the RGB triplet using the formula: (red value) + (256 x green value) + (65536 x blue value), where red value is the first triplet component, green value is the second triplet component, blue value is the third triplet component."

  • Avatar
    Florian Hallensleben

    As far as I am concerned, the formula indicates a #BBGGRR model. However, thank you for clarifying how the value is calculated.


Please sign in to leave a comment.