Skip to content

Commit

Permalink
Fixed use of bytes vs valueBytes in DicomAttributesSink
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlSjostrand committed May 15, 2017
1 parent 0b47550 commit 5fc1700
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Expand Up @@ -36,7 +36,7 @@ object DicomAttributesSink {
if (header.length == 0)
fmi.setNull(header.tag, header.vr)
else {
val bytes = dicomAttribute.bytes.toArray
val bytes = dicomAttribute.valueBytes.toArray
if (!DicomParsing.isGroupLength(header.tag)) {
if (dicomAttribute.bigEndian != fmi.bigEndian) header.vr.toggleEndian(bytes, false)
fmi.setBytes(header.tag, header.vr, bytes)
Expand All @@ -52,7 +52,7 @@ object DicomAttributesSink {
attributesData
}
else {
val bytes = dicomAttribute.bytes.toArray
val bytes = dicomAttribute.valueBytes.toArray
if (!DicomParsing.isGroupLength(header.tag)) {
if (attributesData.attributesStack.nonEmpty && dicomAttribute.bigEndian != attributesData.attributesStack.head.bigEndian)
header.vr.toggleEndian(bytes, false)
Expand Down
7 changes: 4 additions & 3 deletions src/test/scala/se/nimsa/dcm4che/streams/DicomPartsTest.scala
Expand Up @@ -47,8 +47,9 @@ class DicomPartsTest extends FlatSpecLike with Matchers {
val value = DicomValueChunk(false, patientNameJohnDoe.drop(8) ,true)
val attribute = DicomAttribute(header, Seq(value))
val updatedAttribute = attribute.withUpdatedStringValue("Jimmyboy^Doe")
updatedAttribute.bytes.size shouldEqual 12
updatedAttribute.valueBytes.size shouldEqual 12
updatedAttribute.header.length shouldEqual 12
updatedAttribute.bytes.size shouldEqual 20
}

it should "should return a new attribute with updated header and updated value with padding" in {
Expand All @@ -58,8 +59,8 @@ class DicomPartsTest extends FlatSpecLike with Matchers {
val attribute = DicomAttribute(header, Seq(value))
val updatedAttribute = attribute.withUpdatedStringValue("Jimmy^Doe")

updatedAttribute.bytes.size shouldEqual 10
updatedAttribute.valueBytes.size shouldEqual 10
updatedAttribute.header.length shouldEqual 10
updatedAttribute.bytes.drop(9) shouldEqual ByteString(32)
updatedAttribute.valueBytes.drop(9) shouldEqual ByteString(32)
}
}

0 comments on commit 5fc1700

Please sign in to comment.