Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix padding value for IS and DS vrs #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DICOM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ function dcm_store(st::IO, gelt::Tuple{UInt16,UInt16}, writef::Function, vr::Str
vr == "SQ" || gelt == (0xFFFE, 0xE000) ? write(st, convert(lentype, 0xffffffff)) : write(st, convert(lentype, max(0, sz)))
seek(st, endp)
if szWasOdd
vr in ("AE", "CS", "SH", "LO", "PN", "DA", "DT", "TM") ? write(st, UInt8(0x20)) : write(st, UInt8(0))
vr in ("AE", "CS", "SH", "LO", "PN", "DA", "DT", "TM", "IS", "DS") ? write(st, UInt8(0x20)) : write(st, UInt8(0))
end
end

Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,16 @@ end
SOPClassUID = write_to_string(io -> DICOM.write_element(io, (0x0008, 0x0016), "1.2.840.10008.5.1.4.1.1.4", true, empty_vr_dict))
@test length(SOPClassUID) % 2 == 0
@test SOPClassUID[end] == '\0'

# Test that SH strings are padded with ' ' to even length
StudyDescription = write_to_string(io -> DICOM.write_element(io, (0x0008, 0x1030), "BestImageEver", true, empty_vr_dict))
@test length(StudyDescription) % 2 == 0
@test StudyDescription[end] == ' '

# Test that DS strings are padded with ' ' to even length
PixelSpacing = write_to_string(io -> DICOM.write_element(io, (0x0028, 0x0030), [0.5, 0.5], true, empty_vr_dict))
@test length(PixelSpacing) % 2 == 0
@test PixelSpacing[end] == ' '
end

@testset "Writing Sequence" begin
Expand Down
Loading