Fix scaling the legend and scalebar when the resolution is changing (#5029)