现在的位置: 首页 > 综合 > 正文

bmp 到IplImage的转换

2013年04月08日 ⁄ 综合 ⁄ 共 561字 ⁄ 字号 评论关闭
 

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://juwen.blog.51cto.com/135311/86209
用上一篇的文章bmp=>iplimage的转换出来的图像单色,而且效果很差。我重新改了一下。其它部分以后更新。
原来方法:
IplImage * BmpTOIpl(int width,int height,unsigned char  *pBuffer)
{
    IPlImage 
*image =cvCreateImage(cvSize(width,height),8,1);
   image
->imageData=pBuffer;
   
return image;
}

更改之后方法:
IplImage * BmpTOIpl(int width,int height,unsigned char  *pBuffer)
{
   IplImage *image =new IplImage;
   cvInitImageHeader(image, cvSize(width,height), 8, 3,IPL_ORIGIN_BL, 4); //创建iplimage
 cvSetData(image, pBuffer, width*3); //copy数据
   return image;
}

抱歉!评论已关闭.