Never used OpenCV / IplImage before but google revealed this:
http://www.c-plusplus.de/forum/viewt...art-is-10.html
IplImage *img= ...
for (int y=0;y<img->height;y++)
{
unsigned int *dst= (unsigned int*)image->scanLine(y);
unsigned char *src= (unsigned char*)img->imageData + y*img->width*3;
for (int x=0;x<img->width;x++,src+=3)
{
*dst++= src[0] | (src[1]<<8) | (src[2]<<16) | (0xff<<24);
}
}
IplImage *img= ...
QImage *image= new QImage(img->width, img->height, QImage::Format_RGB32);
for (int y=0;y<img->height;y++)
{
unsigned int *dst= (unsigned int*)image->scanLine(y);
unsigned char *src= (unsigned char*)img->imageData + y*img->width*3;
for (int x=0;x<img->width;x++,src+=3)
{
*dst++= src[0] | (src[1]<<8) | (src[2]<<16) | (0xff<<24);
}
}
To copy to clipboard, switch view to plain text mode
You just have to turn it around and make sure the destination format is right.. And you may need to adapt the pixel stride (src+=3 ) to whatever your source is.. look for uses of scanLine.
Johannes
Bookmarks