19.03.2015, 10:22
At the very least, the right shift in your HexToInt function for red is wrong. This should be 24. Also you should use the logical right shift (>>>, three shevrons) instead of the arithmetic right shift (>>). With the arithmetic right shift the number will be padded with the value of the MSB, so if you try to shift anything with a red value greater than 7F the number will be padded with 1 in the front and you will end up with very weird results.