Creating Bitmap Thumbnails with StoreSCP

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
AndreasKnopke
Posts: 49
Joined: Wed, 2005-02-16, 16:27

Creating Bitmap Thumbnails with StoreSCP

#1 Post by AndreasKnopke »

Hi OFFIS team,

I tried to implement an on-the-fly thumbnail creation into StoreSCP.exe (3.5.3) which works fine except for the fact, that this gives a memory leak. Since I am not very familiar with C++, could you give me a hint were the leak might be produced?
I placed this code directyl after the storing of the Fileset to disc with SaveToFile.

Thanks in advance,

Regards,
Andreas


// now create thumbnail image
if ((*imageDataSet)->tagExistsWithValue(DCM_PixelData,OFFalse))

{
DicomImage *di = new DicomImage(cbdata->dcmff, xfer, CIF_MayDetachPixelData, 0, 1);

if ((di != NULL)&&(di->getStatus() == EIS_Normal))

{

di->setWindow(0);
const unsigned long lwidth = 200;
const unsigned long lheight = 0;

di = di->createScaledImage(lwidth, lheight, 1, 1);

di->writeBMP(bmpFilename.c_str(),24,0);
}

delete di;
}
//end creation of thumbnail image

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

The problem with your code is that you have two objects on the heap (one create by "new" and the other one create by "createScaledImage") but delete only one of them (i.e. the latter). I would suggest that you use another variable for the return value of "createScaledImage" and delete both DicomImage objects at the end of your code.

AndreasKnopke
Posts: 49
Joined: Wed, 2005-02-16, 16:27

#3 Post by AndreasKnopke »

Thank you very much!

I somehow missed the fact that createScaledImage actually creates a new object. Now everything works as expected.

Andreas

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest