bitmap functions and conversion to png