当前位置:网站首页>Determine whether the file is a DICOM file

Determine whether the file is a DICOM file

2022-07-07 05:44:00 Dump you for thousands of miles

The basis of judgment : according to DICOM Prefix , The length is 4 Whether a string of bytes is equal to “DICM” To determine whether the file belongs to DICOM file

 Insert picture description here

/ Determine whether the target file is DICOM file /
bool IsDicomFile(QString path)
{
// Judge whether it is dicom file
char buffer[0x85];
std::string s = path.toStdString();
std::ifstream in(path.toStdString().c_str());
in.getline(buffer, 0x85);
if (!((buffer[0x80] == 0x44) && (buffer[0x81] == 0x49) &&
(buffer[0x82] == 0x43) && (buffer[0x83] == 0x4D)))
{
std::cout << path.toStdString() << std::endl;
std::cout << “It’s not a DICOM File!” << std::endl;
return false;
}
return true;
}

原网站

版权声明
本文为[Dump you for thousands of miles]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207062354283070.html