先把代码贴出来:
---------------------------------------------------------------------------------------------------------------------------------------
void Video::RGB2Image(uchar *srcBuf, int w, int h, QImage *pDistImage) {
int i;
int r, g, b;
QRgb *point;
uchar *bit;
i = 0;
bit = (uchar *) (srcBuf);
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
/* Please attion the Littile-Edian and Big-Edian,
* The Order maybe R-G-B.
*/
b = (int) bit
;
g = (int) bit[i + 1];
r = (int) bit[i + 2];
point = (QRgb *) pDistImage->scanLine(y) + x;
*point = qRgb(r, g, b);
i += 3;
}
}
/*矩阵转换功能,将图像的纵坐标倒置*/
QMatrix matrix;
matrix.scale(1, -1);
printf ("point = %ld\nbit = %ld\npDistImage = %ld\n", point, bit, pDistImage);
*pDistImage = pDistImage->transformed(matrix);
}
---------------------------------------------------------------------------------------------------------------------------------------
函数名: RGB2Image
功能 : 将rgb的数据转换成图片
参数 :uchar * srcBuf :保存rgb数据的变量 输入参数
int w: 图片宽度 输入参数
int h:图片高度 输入参数
QImage *pDistImage:目标图片 输出参数
---------------------------------------------------------------------------------------------------------------------------------------
我在一个虚拟机下挂载了两个相同的mx27的板子,然后在不同的文件夹下运行程序,这两个程序时可以交互通信的,每当我运行这两个程序交互通信时到*pDistImage = pDistImage->transformed(matrix);这句时就出现****glibc detected****:double free or corruption (! prev):0x001600032;这样的错误,从报错的理解上是对同一地址free了两次,但是我不是很明白为什么,一直想找transformed()这个函数的里面内容也没找到,不知道这个方法使用的时候有什么问题。
另外,如果程序是和其他未用QT的产品通信,并不会出现错误,也就是说一个程序运行时是不会有问题的。
如果哪位高手知道,请告诉小弟,真的很急![ 此帖被kafeikejian在2009-11-05 15:34重新编辑 ]