Wow, nvm - just figured it out.
Have alpha be first, not last.
But if someone could confirm that and/or check the above code I'd appreciate it.
I don't think you want to be dividing by 0xff, 0xffff, and 0xffffff, but rather by 0x100, 0x10000, and 0x1000000. In particular, 0xff00 / 0xff = 0x100 = 256, which is not in the range of 0 to 255. You can also speed things and use the shift right (>>) operator rather than divide:
unsigned int red = (hex & 0x00ff0000) >> 16;
Reputation Points: 2614
Solved Threads: 687
Posting Expert
Offline 5,374 posts
since Jan 2008