  High-pressure diamond anvil cells have been widely used to create novel
states of matter. Nevertheless, the lack of universal in-situ magnetic
measurement techniques at megabar pressures makes it difficult to understand
the underlying physics of materials' behavior at extreme conditions, such as
high-temperature superconductivity of hydrides and the formation or destruction
of the local magnetic moments in magnetic systems, etc. Here we break through
the limitations of pressure on quantum sensors and develop the in-situ magnetic
detection technique at megabar pressures with high sensitivity
(~1{\mu}T/Hz^(1\2)) and sub-microscale spatial resolution. By directly imaging
the magnetic field and the evolution of magnetic domains, we observe the
macroscopic magnetic transition of Fe3O4 in the megabar pressure range from
strong ferromagnetism ({\alpha}-Fe3O4) to weak ferromagnetism ({\beta}-Fe3O4)
and finally to non-magnetism ({\gamma}-Fe3O4). The scenarios for magnetic
changes in Fe3O4 characterized here shed light on the direct magnetic
microstructure observation in bulk materials at high pressure and contribute to
understanding the mechanism of magnetic moment suppression related to spin
crossover. The presented method can potentially investigate the spin-orbital
coupling and magnetism-superconductivity competition in magnetic systems.
