To make full use of the processing residues of Pterocarpus macrocarpus Kurz and reduce the environmental pollution caused by synthetic dyes, natural dye was extracted from Dalbergia bariensis Pierre heartwood. The purpose of the work was to prepare natural dyes of Pterocarpus macrocarpus and identify the key color-producing components to better explore the mechanisms of combination between dyes and eucalyptus veneers. The main components of Pterocarpus macrocarpus heartwood were analyzed by ultra-high performance liquid chromatography with quadrupole-electrostatic field Orbitrap high resolution-mass spectrometry (UPLC-Q-EXACTIVE Orbitrap-MS). The best dyeing process and color fastness were measured. Research technology combining Fourier transform infrared spectroscopy (FTIR) and field emission scanning electron microscopy (FESEM) was used to explore the binding mechanism between eucalyptus veneers and dyestuffs. The UPLC-Q-EXACTIVE Orbitrap-MS results showed 16 flavonoids. The optimal dyeing process parameters of eucalyptus veneer were a 90 °C dyeing temperature, 12 h dyeing time, 4 wt% pigment, and 2 wt% NaCl. The FTIR and FESM results revealed that the dyeing was mainly achieved by physical adsorption and intermolecular hydrogen bonding.