Get color index

This thread should answer your question.