dcmj2pnm problem with STDOUT

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
hollebolle
Posts: 28
Joined: Tue, 2005-09-20, 10:09

dcmj2pnm problem with STDOUT

#1 Post by hollebolle »

Hi everybody,

I am trying to develop a WADO-server, where dcmj2pnm converts a DICOM-file to JPG with

Code: Select all

dcmj2pnm +oj +Jq 90 +Wi 1 C:\dicom\test.dcm
So, I am not creating a file, I am using the STDOUT for my Outputstream in the webserver-software with content-type: image/jpeg.

The generated jpg in my Browser looks like:
Image
instead of
Image

Has anybody an idea what this could be? Is dcmj2pnm working correctly with STDOUT?

Thanks in advance and kind regards.

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

In your case, the output is binary data (JPEG) and you seem to use Windows. I'm not sure whether Windows really supports binary data on stdout ... but this is just a guess.

Using a temporary file should always work.

hollebolle
Posts: 28
Joined: Tue, 2005-09-20, 10:09

#3 Post by hollebolle »

Hi Jörg,

yes, that is possible. I'm working on windows. With a temporary file it's working fine. But that would have been too easy :wink: .

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#4 Post by Jörg Riesmeier »

It seems that Windows always opens the standard output in text mode. Maybe, something like the following works in order to overcome this:

Code: Select all

freopen(NULL, "wb", stdout);
However, I haven't tested it. Searching for this issue on the Internet might also help ...

gurbuz
Posts: 1
Joined: Wed, 2010-04-21, 03:39

#5 Post by gurbuz »

You can see from Joerg's comments in dcm2pnm that stdout has not been verified for Windows:
Revision 1.50 2001/11/09 16:35:20 joergr
...
Added support for the direct output of the converted PNM/PGM/BMP image to the 'stdout' stream (not yet tested under Windows).

Try this fix. It worked for us.

Code: Select all

#ifdef WIN32
setmode(fileno(stdout), O_BINARY);
#endif

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#6 Post by Jörg Riesmeier »

Thank you for the follow-up. We will add this code line to the prepareCmdLineArgs() function for Windows systems.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest