Opencv内存jpg图像解码和编码[转]

CV_IMPL CvMat* cvEncodeImage( const char* ext,const CvArr* arr, const int* _params )

CV_IMPL IplImage* cvDecodeImage( const CvMat* _buf, int iscolor )
据说可以编码bmp, png, ppm and tiff (encoding only).

解码测试例子:

f=fopen("a.jpg","r");
unsigned char *m=(unsigned char*)malloc(1267*791);
fread(m,50000,1,f);

CvMat mat = cvMat(1267,791,CV_8UC1, m);
IplImage *p = cvDecodeImage( &mat, 1 );
cvNamedWindow("a");

cvShowImage("a",p);
cvWaitKey(0);

posted @ 2013-11-02 22:55  xingrun  阅读(4439)  评论(0编辑  收藏  举报