bugfix: moving variable to its correct scope

this is due if a img has alpha, the bmp need to be cleared.