InsertBitmapValue Example for C++ 6.0 and later

void CDicomDlg::TestProcInsertBitmap()
{
   long lCount;
   short nRet;
   
   m_pLEADDicomDS->EnableMethodErrors = FALSE;
   
   //move to the first image element and delete what's there
   nRet = m_pLEADDicomDS->FindFirstElement (TAG_PIXEL_DATA, FALSE);
   nRet = m_pLEADDicomDS->DeleteElement();
   nRet = m_pLEADDicomDS->InsertElement (FALSE, TAG_PIXEL_DATA, VR_OB, FALSE, 0);
   
   m_List1.ShowWindow(SW_HIDE);
   m_LEADRasterView1.ShowWindow(SW_SHOW);
   
   //load an image
   ILEADRasterIO *pRasterIO=NULL;
   HRESULT hr;
   hr = CoCreateInstance(CLSID_LEADRasterIO,
                         NULL,
                         CLSCTX_ALL,
                         IID_ILEADRasterIO,
                         (void**)&pRasterIO);
   pRasterIO->EnableMethodErrors = FALSE;
   pRasterIO->Load(m_LEADRasterView1.GetRaster(),"d:\\ltwin\\images\\image1.cmp", 0, 1, 1);
   pRasterIO->Release();
   AfxMessageBox("Image loaded from File - Wait");
   
   lCount = m_pLEADDicomDS->GetBitmapCount();
   
   //insert some images
   nRet = m_pLEADDicomDS->InsertBitmapValue(m_LEADRasterView1.GetRaster().GetBitmap(), lCount, DICOM_IMAGE_COMPRESSION_NONE, DICOM_IMAGE_PHOTOMETRIC_RGB, 0, 0, DICOM_SETIMAGE_AUTO_SET_VOI_LUT);
   
   if(nRet != 0)
   {
      AfxMessageBox("Error");
      return;
   }

   ILEADRasterProcess *pRasterProcess=NULL;
   hr = CoCreateInstance(CLSID_LEADRasterProcess,
                         NULL,
                         CLSCTX_ALL,
                         IID_ILEADRasterProcess,
                         (void**)&pRasterProcess);
   pRasterProcess->EnableMethodErrors = FALSE;
   pRasterProcess->Flip(m_LEADRasterView1.GetRaster());
   nRet = m_pLEADDicomDS->InsertBitmapValue (m_LEADRasterView1.GetRaster().GetBitmap(), lCount + 1, DICOM_IMAGE_COMPRESSION_NONE, DICOM_IMAGE_PHOTOMETRIC_RGB, 0, 0, DICOM_SETIMAGE_AUTO_SET_VOI_LUT);
   if(nRet != 0)
   {
      AfxMessageBox("Error");
      return;
   }
   pRasterProcess->Reverse(m_LEADRasterView1.GetRaster());
   pRasterProcess->Release();
   nRet = m_pLEADDicomDS->InsertBitmapValue (m_LEADRasterView1.GetRaster().GetBitmap(), lCount + 2, DICOM_IMAGE_COMPRESSION_NONE, DICOM_IMAGE_PHOTOMETRIC_RGB, 0, 0, DICOM_SETIMAGE_AUTO_SET_VOI_LUT);
   if(nRet != 0)
   {
      AfxMessageBox("Error");
      return;
   }
   
   AfxMessageBox("Images inserted - Wait");
}