I'm fairly new to dcmtk - but not to dicom itself - and I'm having a problem while writing a multiframe dicom from multiple jpeg images.
Here is the simplified code to help you understand my issue (i'm using some wizardry because we are still using C++98 and I can only use specific libraries):
First, the necessary include :
Code: Select all
#include "dcmtk/dcmjpeg/djrplol.h"
#include "dcmtk/dcmjpeg/djencode.h"
Code: Select all
DJEncoderRegistration::registerCodecs();
DJ_RPLossless params;
DcmFileFormat fileFormat;
DcmDataset * dataset_multiframe = fileFormat.getDataset();
DcmPixelData * newPixelData = new DcmPixelData(DCM_PixelData);
dataset_multiframe->insert(newPixelData, OFTrue);
// Create QBYteArray to handle transfer
QByteArray * ba = new QByteArray();
Code: Select all
dataset_multiframe->putAndInsertString(DCM_TransferSyntaxUID, UID_JPEGProcess14TransferSyntax);
dataset_multiframe->putAndInsertString(DCM_PhotometricInterpretation,"RGB");
dataset_multiframe->putAndInsertUint16(DCM_SamplesPerPixel,3);
dataset_multiframe->putAndInsertUint16(DCM_PlanarConfiguration,0);
dataset_multiframe->putAndInsertUint16(DCM_BitsAllocated,8);
dataset_multiframe->putAndInsertUint16(DCM_BitsStored,8);
dataset_multiframe->putAndInsertUint16(DCM_HighBit,7);
dataset_multiframe->putAndInsertUint16(DCM_PixelRepresentation,0);
dataset_multiframe->putAndInsertUint16(DCM_NumberOfFrames,nbFrame);
dataset_multiframe->putAndInsertUint16(DCM_Rows,picture->height()); // Picture is a QImage containing the first JPEG image aka first frame of my dicom
dataset_multiframe->putAndInsertUint16(DCM_Columns,picture->width());
dataset_multiframe->putAndInsertString(DCM_BurnedInAnnotation, "NO");
dataset_multiframe->putAndInsertString(DCM_SOPClassUID, UID_MultiframeTrueColorSecondaryCaptureImageStorage);
Code: Select all
for(unsigned short int i = 0; i < nbFrame ; i++)
{
// ba is a QByteArray containing the bytes of the i-th image
OFCondition status = dataset_multiframe->putAndInsertUint8Array(DCM_PixelData, reinterpret_cast<Uint8 *>(ba), ba->size());
OFCondition status2 = dataset_multiframe->chooseRepresentation(EXS_JPEGProcess14, ¶ms);
}
Thanks a lot for your time and answer and have all a great day !
EDIT : The error does not appear if I use LittleEndianImplicit instead but I get a dicom with one whole black frame (seems normal to me because the data in QByteArray are from a JPEG Image)