Skip to content

Commit bcf0a91

Browse files
committed
add getFrameSize
1 parent ad5e683 commit bcf0a91

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

src/nyx/dicom_util.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "dcmtk/config/osconfig.h" // For DCMTK_VERSION_NUMBER and config macros
2+
#include "dcmtk/dcmdata/dctk.h" // Core DICOM toolkit (includes DcmDataset, DcmPixelData, etc.)
3+
#include "dcmtk/dcmdata/dcpixel.h" // For DcmPixelData
4+
#include "dcmtk/dcmdata/dcdeftag.h" // For DCM_PixelData tag
5+
6+
Uint32 getFrameSize(DcmDataset* dataset)
7+
{
8+
DcmPixelData* pixelData = nullptr;
9+
if (dataset->findAndGetElement(DCM_PixelData, pixelData).bad() || !pixelData)
10+
return 0;
11+
12+
Uint32 frameSize = 0;
13+
#if DCMTK_VERSION_NUMBER >= 0x036800
14+
// DCMTK 3.6.8+ expects a boolean indicating uncompressed state
15+
OFBool isUncompressed = (pixelData->transferState() == ERW_memory);
16+
status = pixelData->getUncompressedFrameSize(dataset, frameSize, isUncompressed);
17+
#else
18+
// DCMTK 3.6.7 signature without boolean
19+
status = pixelData->getUncompressedFrameSize(dataset, frameSize);
20+
#endif
21+
return status.good() ? frameSize : 0;
22+
}

src/nyx/nyxus_dicom_loader.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifdef DICOM_SUPPORT
22
#pragma once
33
#include "abs_tile_loader.h"
4-
#include "dcmtk/dcmdata/dctk.h"
4+
#include "dicom_util.h"
55
#include "dcmtk/dcmjpeg/djdecode.h" /* for JPEG decoders */
66
#include "dcmtk/dcmjpls/djdecode.h" /* for JPEG-LS decoders */
77
#include "dcmtk/dcmdata/dcrledrg.h" /* for RLE decoder */
@@ -232,8 +232,7 @@ class NyxusGrayscaleDicomLoader : public AbstractTileLoader<DataType>
232232
auto status = ds->findAndGetElement(DCM_PixelData, pixel_data_ptr);
233233
if(status.good()){
234234
DcmPixelData* pixel_data = OFreinterpret_cast(DcmPixelData*, pixel_data_ptr);
235-
uint32_t frame_size = 0;
236-
pixel_data->getUncompressedFrameSize(ds,frame_size);
235+
uint32_t frame_size = getFrameSize(ds);
237236
frame_size % 2 == 0 ? frame_size = frame_size : frame_size = frame_size + 1; // need to be even
238237

239238
auto buffer = std::vector<FileType>(data_length);

src/nyx/raw_dicom.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#ifdef DICOM_SUPPORT
4-
#include "dcmtk/dcmdata/dctk.h"
4+
#include "dicom_util.h"
55
#include "dcmtk/dcmjpeg/djdecode.h" /* for JPEG decoders */
66
#include "dcmtk/dcmjpls/djdecode.h" /* for JPEG-LS decoders */
77
#include "dcmtk/dcmdata/dcrledrg.h" /* for RLE decoder */
@@ -253,8 +253,7 @@ class RawDicomLoader : public RawFormatLoader
253253
auto status = ds->findAndGetElement(DCM_PixelData, pixel_data_ptr);
254254
if (status.good()) {
255255
DcmPixelData* pixel_data = OFreinterpret_cast(DcmPixelData*, pixel_data_ptr);
256-
uint32_t frame_size = 0;
257-
pixel_data->getUncompressedFrameSize(ds, frame_size);
256+
uint32_t frame_size = getFrameSize(ds);
258257
frame_size % 2 == 0 ? frame_size = frame_size : frame_size = frame_size + 1; // need to be even
259258

260259
auto buffer = std::vector<FileType>(data_length);

0 commit comments

Comments
 (0)