0

I make an image in memory and then I need the resulting base64 string encoding; actually I use the code in How do I base64 encode (decode) in C? but it works on image in jpg format; so, I need to do the intermediate step to save my image (that is in memory in RGB format) so that I have it in jpeg, then reload it in a stream and finally I can use CBase64

        save_jpeg("temp.jpg");
        std::ifstream iss("temp.jpg",std::ios::binary);
        CBase64 cb;
        std::ostringstream oss;
        cb.Encode(iss,oss);
        return oss.str();

I would avoiding save the jpeg format on disk and then reloading it; for me is not important the format of the resulting cbase64 (jpeg, bmp, etc.) is just important that coping it in an HTML I can view it.

Community
  • 1
  • 1
volperossa
  • 1,339
  • 20
  • 33

0 Answers0