Backported bitmap decoder from 1.1 branch