C++ Base64 Image encoding of already loaded image
<p>I make an image in memory and then I need the resulting base64 string encoding; actually I use the code in <a href="https://stackoverflow.com/questions/342409/how-do-i-base64-encode-decode-in-c">How do I base64 encode (decode) in C?</a> 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</p>

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

<p>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.</p>