I have a color image represented in OpenCV convention where each pixel is represented as unsigned char
in BGR order row after row:
const int BGR = 3;
const int rows= 256;
const int cols = 512;
unsigned char rawIm[BGR * rows *cols] = {'g', 't', 'y', // lots of chars.....}
I want to convert this stream into a base64 string which represents the corresponding jpeg image without actually writing the image on the disk, just "plain" bytes transformation. How can I do that in C++?
For the image to jpeg part, you can use toojpeg which is much easier to use than libjpeg. https://create.stephan-brumme.com/toojpeg/
But you'll have to reverse the BGR to RGB first, because toojpeg does not support BGR yet.
Here is an example: