Roles of resonances and recollisions in strong-field atomic phenomena. II. High-order harmonic generation