There are multiple libraries around for doing this that will take pretty much anything in RGB pixel format. One is called AAlib, comes with almost every linux distro... It's cool because you can hook it up to video sources like DVD
http://aa-project.sourceforge.net/aalib/