Thanks Jörg, you are right, is not getOutputData what is causing the slow performance, the bottleneck is loadFromData.
I used a QTimer to measure the time loadFromData consumes, an I'm getting 125ms aprox on each call. This is too much while doing W/L transformations, compared to Aeskulap, for example.
This is the code I'm using to paint the pixmap. Do you find something that can be improved/optimized?.
Code: Select all
void QDicomImage::getQPixmap(QPixmap &pixmap)
{
QTime myTimer;
myTimer.start();
QString s;
s.setNum(myTimer.elapsed());
qDebug("Start:" + s.toAscii());
DJDecoderRegistration::registerCodecs();
DcmRLEDecoderRegistration::registerCodecs();
const int width = (int)(d->m_dicomImage->getWidth());
const int height = (int)(d->m_dicomImage->getHeight());
char header[32];
int PPM = 0;
if (PPM!=0 &&PPM!=2)
sprintf(header, "P6\n%i %i\n65535\n",width, height);
else
sprintf(header, "P5\n%i %i\n65535\n",width, height);
int offset = strlen(header);
unsigned int length=(d->m_dicomImage->getOutputDataSize (8));
Uint8 *buffer = new Uint8[length+offset];
if (buffer != NULL)
{
OFBitmanipTemplate<Uint8>::copyMem((const Uint8 *)header, buffer, offset);
bool t=d->m_dicomImage->getOutputData((buffer+offset), length, 8);
if (PPM!=0){//on a un PPM
s.setNum(myTimer.elapsed());
qDebug("before loadFromData:" + s.toAscii());
if (!pixmap.loadFromData((const unsigned char *)buffer, (length+offset), "PPM",Qt::AvoidDither))
{
// delete pixmap;
pixmap = NULL;
}
s.setNum(myTimer.elapsed());
qDebug("after loadFromData:" + s.toAscii());
}
else//on charge un PGM
{
s.setNum(myTimer.elapsed());
qDebug("before loadFromData:" + s.toAscii());
if (!pixmap.loadFromData((const unsigned char *)buffer,(length+offset), "PGM", Qt::AvoidDither))
{
// delete pixmap;
pixmap = NULL;
}
s.setNum(myTimer.elapsed());
qDebug("after loadFromData:" + s.toAscii());
}
}
DJDecoderRegistration::cleanup();
DcmRLEDecoderRegistration::cleanup();
}