comments
gamma is in swap, all colors are 16 bit, removing extern c stuff where possible