InsertBitmapListValue Example for C++ 6.0 and later
void CDicomDlg::TestProcInsertList()
{
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");
//create a bitmap list
BSTR lpLic = SysAllocString(_szLicString);
ILEADRasterFactory *pFactory=NULL;
ILEADRaster *pRaster=NULL;
CoCreateInstance(CLSID_LEADRasterFactory, NULL, CLSCTX_ALL, IID_ILEADRasterFactory, (void**)&pFactory);
#if _MSC_VER < 1200
pRaster = (ILEADRaster*)pFactory->CreateObject ("LEADRaster.LEADRaster", lpLic);
#else
ILEADRasterPtr spLEADRaster=NULL;
spLEADRaster = pFactory->CreateObject ("LEADRaster.LEADRaster", lpLic);
pRaster = spLEADRaster;
pRaster->AddRef();//because when spLEADRaster goes out of scope, it will auto Release()!
#endif
pFactory->Release();
SysFreeString(lpLic);
ILEADRasterProcess *pRasterProcess=NULL;
hr = CoCreateInstance(CLSID_LEADRasterProcess,
NULL,
CLSCTX_ALL,
IID_ILEADRasterProcess,
(void**)&pRasterProcess);
pRasterProcess->EnableMethodErrors = FALSE;
pRaster->InsertBitmapListItem(0, m_LEADRasterView1.GetRaster().GetBitmap());
pRasterProcess->Flip(m_LEADRasterView1.GetRaster());
pRaster->InsertBitmapListItem(1, m_LEADRasterView1.GetRaster().GetBitmap());
pRasterProcess->Reverse(m_LEADRasterView1.GetRaster());
pRaster->InsertBitmapListItem(2, m_LEADRasterView1.GetRaster().GetBitmap());
pRasterProcess->Release();
//insert the image list into the element
nRet = m_pLEADDicomDS->InsertBitmapListValue(pRaster->GetBitmapList(), 0, DICOM_IMAGE_COMPRESSION_NONE, DICOM_IMAGE_PHOTOMETRIC_RGB, 0, 0, DICOM_SETIMAGE_AUTO_SET_VOI_LUT);
pRaster->Release();
if(nRet != 0)
{
AfxMessageBox("Error");
return;
}
AfxMessageBox("ImageList inserted into Data Set - Wait");
}