我发现将png文件转换为base64,但需要像这样从文件流中读取:
ostringstream sout;
istringstream sin;
// this is the object we will use to do the base64 encoding
base64 base64_coder;
// now base64 encode the compressed data
base64_coder.encode(sin,sout);
我在OpenCV中有一个PNG格式的图像,转换为:
imencode(".png", im, buf);
当我想要转换时,
base64_coder.encode(buf,sout);
这里涉及到it技术。
我对c ++的了解有限,因此需要任何帮助。
目的是:
我需要将png图像写入mongodb,以便meteorjs使用。因此,它们要求图像为base64编码。
谢谢
编辑:im为Cv :: Mat . obj。我正在将其转换为png。buf包含png。