Skip to content

[Bug] Uncompressed RGB Explicit VR LE images with DICOM OB pad byte fail to render (model.size is not a multiple of model.numberOfComponents) #6166

Description

@zhenggu544

Describe the Bug

Some uncompressed RGB images (Transfer Syntax 1.2.840.10008.1.2.1, Explicit VR Little Endian) fail to render in StackViewport with: RangeError: model.size is not a multiple of model.numberOfComponents at vtkDataArray.newInstance at StackViewport.createVTKImageData

Steps to Reproduce

  1. Load a study containing an uncompressed Explicit VR LE RGB image where rows * columns * samplesPerPixel is odd (e.g. 917×917 RGB).
  2. Open it in a StackViewport (WADO-RS).
  3. Observe blank/failed render and the VTK RangeError above.

Actual behavior

Viewport fails while creating VTK image data because scalar array length is not divisible by numberOfComponents (3).

The expected behavior

Image renders correctly; pad byte is discarded so:pixelData.length === rows * columns * samplesPerPixel

System Information

  • OHIF Viewer: 3.12.0
  • @cornerstonejs/core: 4.15.29
  • @cornerstonejs/dicom-image-loader: 4.15.29
  • Loading via WADO-RS (wadors:)

Suggested fix

Trim a single trailing pad byte when length is exactly expected + 1 for 8-bit pixel data, before VoxelManager / VTK consume the buffer — e.g. in decodeLittleEndian or immediately after decode in createImage:

const expected = rows * columns * samplesPerPixel; // bitsAllocated === 8
if (pixelData.length === expected + 1) {
  pixelData = pixelData.subarray(0, expected);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions