relocated .bmp-loading code