What is the most efficient way to do this?
相关问题
- DBGrid - How to set an individual background color
- How to display an image represented by three matri
- How to delete a certain part of an Image?
- draw polylines with different colors on v2 maps
- How to Hex Encode a SHA-256 Hash
相关文章
- Emacs/xterm color annoyance on Linux
- How to convert hex string into decimal value
- matplotlib bwr-colormap, always centered on zero
- MeshLab: How to import XYZRGB file
- Converting hex string representation to float in p
- How to add RGB values into setColor() in Java?
- How to convert Byte Array to hex string in visual
- ChartJS. Change axis line color
Modifying Jeremy's python answer to handle short CSS rgb values like 0, #999, and #fff (which browsers would render as black, medium grey, and white):
Real answer: Depends on what kind of hexadecimal color value you are looking for (e.g. 565, 555, 888, 8888, etc), the amount of alpha bits, the actual color distribution (rgb vs bgr...) and a ton of other variables.
Here's a generic algorithm for most RGB values using C++ templates (straight from ScummVM).
Here's a sample color struct for 565 (the standard format for 16 bit colors):
just real quick:
A hex value is just RGB numbers represented in hexadecimal. So you just have to take each pair of hex digits and convert them to decimal.
Example:
In python: