Add old colour detection code fron SVN repository

Added the old colour detection code from the SVN repository.