Preface: Http://www.cnblogs.com/studypanp/p/5002953.html Gets the color value
Before getting to a pixel color value (hex), for example (yellow): ffd1c04c (total eight bits), I think the front two bits represent the transparency, the other order is r-g-b, didn't think the order is G-b-r
The following is a function that resolves RGB from hex: (here is the FF as R)
function Tform2.hexcolortorgb (s:string): string; The color value var i:integer is passed in. R,g,b:byte;begin I: = S.tointeger; R: = i and $FF; G: = (i shr 8) and $FF; B: = (i shr) and $FF;//Result: = Format ('%.2x,%.2x,%.2x ', [r,g,b]); Returns the hexadecimal RGB Result: = Format ('%.2d,%.2d,%.2d ', [r,g,b]); return to Rgb:76,192,209end;
I entered r:76 on the Paint color editor, g:192,b:209, the canvas above is blue, I am depressed ...
Later I put the three numbers in the wrong order, the results found that 192,209,76 is the original color, the number of digits is not in accordance with the order of RGB, but in accordance with the order of BRG, depressed my death
At least that's what I did in XE.
function Tform2.hexcolortorgb (s:string): string; The color value Vari:integer is passed in. R,g,b:byte;begini: = S.tointeger; B: = i and $FF; R: = (i shr 8) and $FF; G: = (i shr) and $FF;//result: = Format ('%.2x,%.2x,%.2x ', [r,g,b]); Returns the hexadecimal rgbresult: = Format ('%.2d,%.2d,%.2d ', [r,g,b]); Returns the RGB 192,209,76end;
So we need to change the order of the original function.
Delphi gets the RGB color value