Last active
March 1, 2016 12:54
-
-
Save luchosrock/173056b39e6acd6b4cd7 to your computer and use it in GitHub Desktop.
VB6 Palette color to RGB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//lbcolor: color en bd (definido en paleta de vb6 designer) | |
int lbcolor = 255; | |
int pBlue = 0; | |
int pRed = 0; | |
int pGreen = 0; | |
if (lbcolor < 256) { | |
pRed = lbcolor; | |
pBlue = 0; | |
pGreen = 0; | |
//exit sub | |
} | |
else{ | |
if (lbcolor < 65280) { | |
pGreen = (int)(lbcolor / 256); | |
pRed = lbcolor - pGreen * 256; | |
pBlue = 0; | |
//exit sub | |
} | |
} | |
pBlue = (int)(lbcolor / 65536); | |
pGreen = (int)((lbcolor - pBlue * 65536) / 256); | |
pRed = lbcolor - pGreen * 256 - pBlue * 65536; | |
//output | |
string output = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(pRed,pGreen,pBlue)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment