I am parsing a XML file supplied by some software. Part of the parsing is extracting colors from some attributes. The problem I have is the color is a 12digit hex value. ie,
<Text AdornmentStyle="0" Background="#FFFFFFFFFFFF" Color="#DD6B08C206A2" Font="Courier Final Draft" RevisionID="0" Size="12" Style="">Test</Text>
As you can see the colors are 12digits long. I need to get the 6 digit color so I can display it correctly on html.
Has anyone come across this before?
Hope you can advise.
Never seen a 12-digit hex color string before. Must be using 2-bytes per channel, which means if you convert it, you’re going to lose a bit of information.
I believe the color is in the format
#RRRRGGGGBBBB, so take each 4 hexgits and divide by (16^4/16^2)=256, and round if necessary. That should do it.…and if that doesn’t give you the right color, try CMYK like cypher suggests:
#CCCMMMYYYKKK(12-bits per channel).e.g., to convert
DD6B08C206A2do:Put those back together and you get
#DD0806.