Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Encode image and copy to char* buffer

Hi I would like to copy encoded image as .png to char* buffer. What I am trying is:

CvMat* mat = cvEncodeImage(".png", img, param);
int bufLen = buffer->step;
unsigned char * pData = buffer->data.ptr;
char* buf;
memcpy( buf, pData, bufLen);

However buffer seems to be empty... I am not sure if I am accessing the data the right way, but I am having a hard time finding a proper documentation for this. Also - this has to be done in raw C (it's part of a bigger project).

Has anyone tried to do something like this before?

Cheers