comparison Core/DicomFormat/DicomMap.cpp @ 3840:e7003b2203a7

fixing signature of DicomMap::ParseDicomMetaInformation()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 15 Apr 2020 22:17:42 +0200
parents 74889e6f6d68
children
comparison
equal deleted inserted replaced
3838:95083d2f6819 3840:e7003b2203a7
743 743
744 return true; 744 return true;
745 } 745 }
746 746
747 747
748 bool DicomMap::IsDicomFile(const char* dicom, 748 bool DicomMap::IsDicomFile(const void* dicom,
749 size_t size) 749 size_t size)
750 { 750 {
751 /** 751 /**
752 * http://dicom.nema.org/medical/dicom/current/output/chtml/part10/chapter_7.html 752 * http://dicom.nema.org/medical/dicom/current/output/chtml/part10/chapter_7.html
753 * According to Table 7.1-1, besides the "DICM" DICOM prefix, the 753 * According to Table 7.1-1, besides the "DICM" DICOM prefix, the
754 * file preamble (i.e. dicom[0..127]) should not be taken into 754 * file preamble (i.e. dicom[0..127]) should not be taken into
755 * account to determine whether the file is or is not a DICOM file. 755 * account to determine whether the file is or is not a DICOM file.
756 **/ 756 **/
757 757
758 const uint8_t* p = reinterpret_cast<const uint8_t*>(dicom);
759
758 return (size >= 132 && 760 return (size >= 132 &&
759 dicom[128] == 'D' && 761 p[128] == 'D' &&
760 dicom[129] == 'I' && 762 p[129] == 'I' &&
761 dicom[130] == 'C' && 763 p[130] == 'C' &&
762 dicom[131] == 'M'); 764 p[131] == 'M');
763 } 765 }
764 766
765 767
766 bool DicomMap::ParseDicomMetaInformation(DicomMap& result, 768 bool DicomMap::ParseDicomMetaInformation(DicomMap& result,
767 const char* dicom, 769 const void* dicom,
768 size_t size) 770 size_t size)
769 { 771 {
770 if (!IsDicomFile(dicom, size)) 772 if (!IsDicomFile(dicom, size))
771 { 773 {
772 return false; 774 return false;
786 size_t position = 132; 788 size_t position = 132;
787 789
788 DicomTag tag(0x0000, 0x0000); // Dummy initialization 790 DicomTag tag(0x0000, 0x0000); // Dummy initialization
789 ValueRepresentation vr; 791 ValueRepresentation vr;
790 std::string value; 792 std::string value;
791 if (!ReadNextTag(tag, vr, value, dicom, size, position) || 793 if (!ReadNextTag(tag, vr, value, reinterpret_cast<const char*>(dicom), size, position) ||
792 tag.GetGroup() != 0x0002 || 794 tag.GetGroup() != 0x0002 ||
793 tag.GetElement() != 0x0000 || 795 tag.GetElement() != 0x0000 ||
794 vr != ValueRepresentation_UnsignedLong || 796 vr != ValueRepresentation_UnsignedLong ||
795 value.size() != 4) 797 value.size() != 4)
796 { 798 {
803 return false; 805 return false;
804 } 806 }
805 807
806 while (position < stopPosition) 808 while (position < stopPosition)
807 { 809 {
808 if (ReadNextTag(tag, vr, value, dicom, size, position)) 810 if (ReadNextTag(tag, vr, value, reinterpret_cast<const char*>(dicom), size, position))
809 { 811 {
810 result.SetValue(tag, value, IsBinaryValueRepresentation(vr)); 812 result.SetValue(tag, value, IsBinaryValueRepresentation(vr));
811 } 813 }
812 else 814 else
813 { 815 {