Welcome Guest! To enable all features, please Login or Register.



Last Go to last post Unread Go to first unread post
#1 Posted : Friday, August 11, 2017 2:54:21 AM(UTC)

Groups: Registered
Posts: 1

I am developing using the C ++ class library v19.
The development environment is Qt 5.8.

I need to read the raw data file and create a dicom file.
Are there any C ++ examples related to this?


I tried this example, but I get an invalid format error.

It is very good when you load a bmp file as a test.

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Friday, August 11, 2017 6:13:34 PM(UTC)


Groups: Tech Support, Administrators
Posts: 311

Was thanked: 3 time(s) in 3 post(s)


When you say you need to read raw data, are you trying to load data from a headerless file or are you referring to just raw image data in memory? Each of these have different solutions.

I don't know of any specific examples to point you to regarding taking raw data and putting it in a DICOM file, but I will try to provide some guidance on how to go about doing it here.

With respect to inserting the image data into a DICOM file, you'll need the image data to be wrapped with our BITMAPHANDLE. This can then be passed to the LDicomDS::InsertImage() method to be put into a dataset. Then you can write the file out.

For a simple test, you could do the following:
1.) Load a BMP
2.) Load a template DICOM file with LoadDS()
3.) Insert the image data (from the BMP) into the dataset with InsertImage()
4.) Save the new DICOM file with SaveDS()

Here's a code snippet for illustration:

L_INT          nRet; 
LDicomDS*      pDS; 
pDS = new LDicomDS(NULL); 
nRet = pDS->LoadDS(L_TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\image1.dcm"), 0); 
if(nRet != DICOM_SUCCESS) 
   return nRet; 
pElement = pDS->FindFirstElement(NULL, TAG_PIXEL_DATA, FALSE); 
if (pElement != NULL) 
   LBitmapBase BitmapBase; 
   BitmapBase.SetFileName(L_TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\cannon.jpg"))); 
   BitmapBase.Load(0,ORDER_BGR, NULL); 

   pBITMAPHANDLE pBitmap = BitmapBase.GetHandle();

   nRet = pDS->InsertImage(pElement, pBitmap, 1, IMAGE_COMPRESSION_NONE, 
   if(nRet != DICOM_SUCCESS) 
      return nRet; 

nRet = pDS->SaveDS(L_TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\temp.dcm")), 0); 
if(nRet != DICOM_SUCCESS) 
    return nRet; 
delete pDS; 

So as long as you can get a pointer to a bitmap to pass to InsertImage(), that should be all that you need. If you just have the raw data in memory, you could create the bitmap handle without the image data first (memory type = TYPE_USER) , and then use SetDataPointer() to provide your user data after the fact.
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2017, Yet Another Forum.NET
This page was generated in 0.148 seconds.