Improved bmpshape.cc