Back to Pneity Home

OLE to RGB (hex) or RGB to OLE style color codes.

I'm too lazy for github.

But nobody else published theirs.

Colors.
I settled in to adding on to a project that sought to convert a decomissioned Flash "application" over to HTML5. I decompile the swf files and dig in. I bust the door open like the Kool-Aid man and there are thirsty kids in that flv file. So anyway, I check the ActionScript code out and it is an unmanagable nightmare. I don't know whether it was the decompiling or just that the code was originally bad, but I couldn't make heads or tails of it.
Everything presented on this page is public domain and I encourage anyone to make your own scripts based on my functions in whatever language suits you best.
So I honestly have no idea how he coded the color choosing algorithm. But it seemed to be using a code where White was equal to 16777215. After some Googling, I learned that this color format hasn't been used since somewhere around Visual Basic 5. Lots of old VB forum posts talking about this OLE coloring scheme. Only two or three posts I found could even explain how it's generated. But it's generated through taking the red value between 0 and 255, adding it to green value between 0 and 255 multiplied by 256, then the blue value between 0 and 255 multiplied by 256 twice.
RGB (hexadecimal)
OLE
Above, you can put in the hexadecimal RGB values you have in the first field and it'll convert you over to the OLE value. It works in reverse, too!

In more plain code/formula:

OLE = 'red' appended to (green * 256) appended to (blue * 256 * 256)

RGB = "red % 255" + "(green / 256) % 256" + "(blue / 256 / 256) % 256"

Examples
000000 --> 0
cccccc --> 13421772
eca742 --> 4368364
ffffff --> 16777215
40420f --> 1000000
44e --> 15615044
ff77cc --> 13400063
f7c --> 13400063
00ffcc --> 13434624
0fc --> 13434624
Credit goes to Tim. Catch him at @turious.pneity.org on bsky or @turious@mastodon.social.