createValueFromTempFile with padding byte
Moderator: Moderator Team
-
- Posts: 34
- Joined: Thu, 2014-07-17, 09:07
createValueFromTempFile with padding byte
I have PixelData that cannot have a padded byte trimmed, but I can add an empty byte (0).
Previously, when calling "createValueFromTempFile", I would modify the fileLen passed to it using "if (fileLen & 1) fileLen--"".
I cannot do this because this last byte is important. I essentially need to do "if (fileLen & 1) fileLen++", but when saving the DCM file, I get "invalid stream".
How do I add a padding byte to the DCM file without modifying the original file?
Previously, when calling "createValueFromTempFile", I would modify the fileLen passed to it using "if (fileLen & 1) fileLen--"".
I cannot do this because this last byte is important. I essentially need to do "if (fileLen & 1) fileLen++", but when saving the DCM file, I get "invalid stream".
How do I add a padding byte to the DCM file without modifying the original file?
-
- Posts: 34
- Joined: Thu, 2014-07-17, 09:07
Re: createValueFromTempFile with padding byte
I have a hack solution, but I really hope there is a better one.
I overrode DcmInputFileStream/DcmInputFileStreamFactory/DcmFileProducer to implement my own DcmFileProducer. All methods are default, but I changed the "read" of the DcmFileProducer.
Thes adds the "0" byte at the end of the video. Is there another (better) solution?
I overrode DcmInputFileStream/DcmInputFileStreamFactory/DcmFileProducer to implement my own DcmFileProducer. All methods are default, but I changed the "read" of the DcmFileProducer.
Code: Select all
offile_off_t PaddedDcmFileProducer::read(void *buf, offile_off_t buflen)
{
offile_off_t result = 0;
if (status_.good() && file_.open() && buf && buflen)
{
result = file_.fread(buf, 1, OFstatic_cast(size_t, buflen));
}
if (result < buflen)
{
if (size_ & 1) result++;
((BYTE*)buf)[result - 1] = 0;
}
return result;
}
-
- DCMTK Developer
- Posts: 2506
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: createValueFromTempFile with padding byte
This specific problem is listed as Feature #296 in our (still internal) issue tracker. I've also added a link to this thread and set the "target version" to "next release" (whenever this will be).
I wrote this posting in order to tell you that the current limitation of createValueFromTempFile() is known to us - of course, as it is documented on API level - and will be solved in a future release of the DCMTK.
I wrote this posting in order to tell you that the current limitation of createValueFromTempFile() is known to us - of course, as it is documented on API level - and will be solved in a future release of the DCMTK.
-
- Posts: 34
- Joined: Thu, 2014-07-17, 09:07
Re: createValueFromTempFile with padding byte
Just curious, has this been implemented?
-
- DCMTK Developer
- Posts: 2506
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: createValueFromTempFile with padding byte
Unfortunately, not. See the now public issue tracker (sorry for the German): http://support.dcmtk.org/redmine/issues/296
-
- Posts: 34
- Joined: Thu, 2014-07-17, 09:07
Re: createValueFromTempFile with padding byte
Would you guys accept a PR? This seems like a trivial fix.
-
- DCMTK Developer
- Posts: 2506
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: createValueFromTempFile with padding byte
We will definitely check your proposal. Please send a patch with the proposed changes by email to bugs/at/dcmtk/dot/org or submit a PR at GitHub.
Who is online
Users browsing this forum: Google [Bot] and 1 guest