Context. The context is the magnetic field measurement in external solar or stellar layers by interpreting line polarization measurements and the Hanle effect. Aims. The aim is to model the Hanle effect depolarization by integrating upon a star on the one hand, and by integrating along a line-of-sight through the solar corona on the other hand. Methods. The formalism of the atomic density matrix is recalled. Particular attention was devoted to the four axis rotations necessary to transform the magnetic field reference frame into that of the line-of-sight. Results. In the stellar case, the discrepancy between the results by López Ariste et al. (2011, A&A, 527, A120) and the symmetry considerations by Ignace etal. (201...