64,644
社区成员
发帖
与我相关
我的任务
分享
CxImage* CReadDicom::GetDcmLocalImageData(CString inPath,CxImage*pImage )
{
//pImage = new CxImage; 这里要注释掉
BOOL bReVal = FALSE;
BYTE * pDicomDibits = NULL;
int nSize = 0;
pImage->Create(pDicomImg->getWidth(), pDicomImg->getHeight(), 24);
nSize = pDicomImg->createWindowsDIB((void*&)pDicomDibits, 0, 0, 24, 1, 1);
if(nSize == pImage->GetEffWidth() * pImage->GetHeight() && pDicomDibits != NULL)
{
memcpy(pImage->info.pImage, pDicomDibits, nSize);
bReVal = TRUE;//正确 20行
}
else
{
bReVal = FALSE;//不正确 23行
}
return pImage;
}
void CImageWnd::GetImageData(CString strPath)
{
m_strPath = strPath;
CReadDicom readDicom;
CxImage * pImage1=new CxImage;
m_pImage = readDicom.GetDcmLocalImageData(strPath,pImage1); //应该是这样
delete pImage1;//在函数外进行new和delete,防止内存泄漏
}
CxImage* CReadDicom::GetDcmLocalImageData(CString inPath,CxImage*pImage )
{
pImage = new CxImage;//为什么这行注销了就会运行23行;不注销,就可以正确到20行
BOOL bReVal = FALSE;
BYTE * pDicomDibits = NULL;
int nSize = 0;
pImage->Create(pDicomImg->getWidth(), pDicomImg->getHeight(), 24);
nSize = pDicomImg->createWindowsDIB((void*&)pDicomDibits, 0, 0, 24, 1, 1);
if(nSize == pImage->GetEffWidth() * pImage->GetHeight() && pDicomDibits != NULL)
{
memcpy(pImage->info.pImage, pDicomDibits, nSize);
bReVal = TRUE;//正确 20行
}
else
{
bReVal = FALSE;//不正确 23行
}
return pImage;
}