Skip to content

Commit

Permalink
fix: Size In Bytes should take into account default use of Float32 (#288
Browse files Browse the repository at this point in the history
)
  • Loading branch information
JamesAPetts authored and swederik committed Mar 21, 2022
1 parent 4f6245f commit 6374316
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,25 @@ function cornerstoneStreamingImageVolumeLoader(

// Check if it fits in the cache before we allocate data
// TODO Improve this when we have support for more types
const bytesPerVoxel = BitsAllocated === 16 ? 2 : 1
const sizeInBytes =
// NOTE: We use 4 bytes per voxel as we are using Float32.
const bytesPerVoxel = BitsAllocated === 16 ? 4 : 1
const sizeInBytesPerComponent =
bytesPerVoxel * dimensions[0] * dimensions[1] * dimensions[2]

let numComponents = 1
if (PhotometricInterpretation === 'RGB') {
numComponents = 3
}

const numBytes = sizeInBytes * numComponents
const sizeInBytes = sizeInBytesPerComponent * numComponents

// check if there is enough space in unallocated + image Cache
const isCacheable = cache.isCacheable(numBytes)
const isCacheable = cache.isCacheable(sizeInBytes)
if (!isCacheable) {
throw new Error(ERROR_CODES.CACHE_SIZE_EXCEEDED)
}

cache.decacheIfNecessaryUntilBytesAvailable(numBytes)
cache.decacheIfNecessaryUntilBytesAvailable(sizeInBytes)

let scalarData

Expand Down

0 comments on commit 6374316

Please sign in to comment.