/* * Copyright (C) 2010-2011, Mathieu Labbe and IntRoLab - Universite de Sherbrooke * * This file is part of RTAB-Map. * * RTAB-Map is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * RTAB-Map is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RTAB-Map. If not, see . */ #include "qtipl.h" #include "utilite/ULogger.h" #include namespace rtabmap { // TODO : support only from gray 8bits ? QImage Ipl2QImage(const IplImage *newImage) { QImage qtemp; if (newImage && newImage->depth == IPL_DEPTH_8U && cvGetSize(newImage).width>0) { int x; int y; char* data = newImage->imageData; qtemp= QImage(newImage->width, newImage->height,QImage::Format_RGB32 ); for( y = 0; y < newImage->height; y++, data +=newImage->widthStep ) { for( x = 0; x < newImage->width; x++) { uint *p = (uint*)qtemp.scanLine (y) + x; *p = qRgb(data[x * newImage->nChannels+2], data[x * newImage->nChannels+1],data[x * newImage->nChannels]); } } } else { ULOGGER_ERROR("Wrong IplImage format"); } return qtemp; } }