Why not support 24-bit color here? I think it's going to do something weird in the 24-bit case by pretending that it's normal and using the red component as an index into the color table. probably should take a mode as an arg rather than the bool fgAlt. Also have a look at the call sites to this method, which currently toss the mode out incorrectly.