you have to repositionate the panel!

photo1_pan->pos_x = 500 - ((photo1_pan->scale_x - 1)/2)*bmap_width(photo1_pan->bmap);
photo1_pan->pos_y = 500 - ((photo1_pan->scale_y - 1)/2)*bmap_height(photo1_pan->bmap);

this way it should work (if 500,500 is the default position of the panel)