I found closed source Windows based programs (ColorImpact, for example) which claim some such capability, but not only does that seem like overkill, it seems as if there should be some simple way to go about this using an open source option.
closed source: http://www.iconico.com/colorPop/
seems like open source--he anyway provides the source code there: http://www.asahi-net.or.jp/~FX6M-FJMY/java09e.html
HTH