dcmtk 中的 memcpy 函数在debug下没问题,在release下崩溃
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;
}