is there anyone in the forum who has already come up with the same question? In Microsoft Word you can set the document background color. It will also be exported to RTF files. The RTF code for the background color looks like this.
Unfortunately, the RTF specification does not provide an exact specification of how the color value is coded. The only thing I could filter out of the code so far is that {\sp{\sn fillColor}{\sv 1261823}} is responsible for the background color. If you play a little with the numerical value, the background color of the RTF file also changes. Does anyone know in which format the color value is coded? I would like to read it out and pass it to a color variable in Xojo.
Unfortunately, it’s not that simple. The background color in the test document is set to red. You can download the RTF here. If I enter your value into a color converter, I get a blue tone.
what do you mean how did I convert the color?
I entered values for colors that I knew, and observed the results. when I entered 16711680 I expected RED but got BLUE therefore the Red and Blue bytes are transposed… once I determined that all other values resulted in the expected color
Sorry, ones again: I understand how to convert this binary value using Hex function to readable color code. What does the calculation of a color given in Xojo look like in this binary format?
for the most part a color is a 24 bit number… a number is a number as far as the computer is concerned. the digits 0-9, and hex representation of for the convience of people
12345678 is 0xBC614E in HEX and 101111000110000101001110 in Binary
Xojo uses RGB where R=Red as a value between 0-255 [0x00 to 0xFF], G=Green, and B=Blue (seems RTF flips Red and Blue)
OK, i made some test. Using the following code and enter the returned rtfColorCode into the RTF, returns not the same Color in Microsoft Word. Looks like there are small differences in calculation:
[code]Dim c As Color = &c470bb7
Dim r As Integer = c.Red * 65536
Dim g As Integer = c.Green * 256
Dim b As Integer = c.Blue
Rim rtfColorCode As Integer = r + g + b ’ Result: 4656055, open it with Word returns &cB70B47[/code]
Thanks David and Ulrich. I can live with the small difference between the color Xojo returns and the color generated by Word from the given Xojo Integer.
The only differnce is that Word swaps the Red and Blue bytes… .otherwise they should render the exact same colors (unless Word uses a non-standard colorspace)