Luminescence and scintillation of PbI2 and HgI2