dcmtk 中的 memcpy 函数在debug下没问题,在release下崩溃

jjpweb 2014-11-25 05:05:48
CxImage* CReadDicom::GetDcmLocalImageData(CString inPath, double dWindCenter, double dWindWidth)
{
DJDecoderRegistration::registerCodecs();
DcmRLEDecoderRegistration::registerCodecs();

DcmFileFormat pDcmFile;
pDcmFile.loadFile(inPath);
DcmDataset *pDataset = NULL;
pDataset = pDcmFile.getDataset();
E_TransferSyntax xfer = pDataset->getOriginalXfer();

OFString temp;
if (!pDataset->findAndGetOFString(DCM_PixelRepresentation, temp,0).good())
{
pDataset->putAndInsertUint16(DCM_PixelRepresentation,0);//1有符号
}
DicomImage *pDicomImg = NULL;
pDicomImg = new DicomImage(pDataset, xfer, CIF_AcrNemaCompatibility , 0, 0);
if (dWindCenter == 0)
{
const char *strWindowCenter, *strWindowWidth;
pDataset->findAndGetString(DCM_WindowCenter,strWindowCenter);
pDataset->findAndGetString(DCM_WindowWidth, strWindowWidth);
pDicomImg->setWindow(_ttoi(strWindowCenter), _ttoi(strWindowWidth));
}
else
pDicomImg->setWindow(dWindCenter, dWindWidth);
EI_Status r = pDicomImg->getStatus();
if(pDicomImg->getStatus() != EIS_Normal)
{
// AfxMessageBox((LPCTSTR)DicomImage::getString(m_pDicomImg->getStatus()));
return FALSE;
}

CxImage * pImage = new CxImage;
BOOL bReVal = FALSE;
//(3)读出的图像数据
BYTE * pDicomDibits = NULL;
int nSize = 0;
//得到DICOM文件第frame 的DIB 数据(假设是24 位的)
pImage->Create(pDicomImg->getWidth(), pDicomImg->getHeight(), 24);

if (!pDicomImg->isMonochrome())
nSize = pDicomImg->createWindowsDIB((void*&)pDicomDibits, 0, 0, 24, 1, 1);
else
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;
}
else
{
bReVal = FALSE;
}
delete pDicomDibits;
pDicomDibits = NULL;

DJDecoderRegistration::cleanup();
DcmRLEDecoderRegistration::cleanup();
return pImage;
}
...全文
193 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jjpweb 2014-11-26
  • 打赏
  • 举报
回复
memcpy(pImage->info.pImage, pDicomDibits, nSize) 这行代码只是调试的时候,在这行出错崩溃
快乐鹦鹉 2014-11-25
  • 打赏
  • 举报
回复
你如何确认这句有问题的?pImage->info.pImage为空否?
hubo86915531 2014-11-25
  • 打赏
  • 举报
回复
memcpy(pImage->info.pImage, pDicomDibits, nSize*3);试试?

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧