Generalized & more portable bitmap functions.