Description
Describe the bug
Dicom Tags with a VR of SV and UV should have a value length field of 16 bits as specified in PS3.5 Section 7.1.2
for VRs of AE, AS, AT, CS, DA, DS, DT, FL, FD, IS, LO, LT, PN, SH, SL, SS, ST, TM, UI, UL and US the Value Length Field is the 16-bit unsigned integer following the two byte VR Field (Table 7.1-2). The value of the Value Length Field shall equal the length of the Value Field.
for all other VRs the 16 bits following the two byte VR Field are reserved for use by later versions of the DICOM Standard. These reserved bytes shall be set to 0000H and shall not be used or decoded (Table 7.1-1). The Value Length Field is a 32-bit unsigned integer.
To Reproduce
DicomDataset ds = new();
ds.Add(DicomTag.SOPClassUID, DicomUID.SecondaryCaptureImageStorage);
ds.Add(DicomTag.SOPInstanceUID, "1.1.1.1");
ds.Add(DicomTag.PatientName, "TEST");
ds.Add(DicomTag.SelectorOVValue, (ulong)1);
ds.Add(DicomTag.SelectorSVValue, (long)2);
ds.Add(DicomTag.SelectorUVValue, (ulong)3);
DicomFile file = new DicomFile(ds);
file.Save(@"d:\ds1.dcm");
View the file with a hex editor
72 00 81 00 4F 56 00 00 08 00 00 00 01 00 00 00 00 00 00 00
72 00 82 00 53 56 08 00 02 00 00 00 00 00 00 00
72 00 83 00 55 56 08 00 03 00 00 00 00 00 00 00
Expected behavior
The OV Tag contains the correct Value Length
The SV and UV tags have only 16 bits for the Value Length
I think this should just be a simple change in DicomVR.cs. Changing the Is16bitLength = false for those two VR's produces the following output
72 00 81 00 4F 56 00 00 08 00 00 00 01 00 00 00 00 00 00 00
72 00 82 00 53 56 00 00 08 00 00 00 02 00 00 00 00 00 00 00
72 00 83 00 55 56 00 00 08 00 00 00 03 00 00 00 00 00 00 00
Environment
Fellow Oak DICOM version: (5.0.2)
OS: Windows 10 64 bit
Platform: .NET 6