1 | initial version |
Solution could be something like this (from the head):
std::vector<uchar> localBuffer;
imencode(".png", img, localBuffer, param);
char *buf = malloc(localBuffer.size());
memcpy(buf, localBuffer.data(), localBuffer.size());
Don't forget to free buf
if you don't need it anymore.