It is shown that binary low-density generator matrix codes can achieve the rate-distortion bound of discrete memoryless sources with general distortion measure via multilevel quantization. A practical encoding scheme based on the surveypropagation algorithm is proposed. The effectiveness of the proposed scheme is verified through simulation.