bitmap code

messy but mostly working