DICOM @ OFFIS

Discussion Forum for OFFIS DICOM Tools - For registration, send email with desired user name to the OFFIS DICOM team
It is currently Tue, 2018-08-14, 09:53

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri, 2016-10-28, 14:46 
Offline

Joined: Tue, 2008-09-16, 15:02
Posts: 169
Hi,
I want to convert a Dicom Image to JPEG stream. To make this I'm trying to redirect the stdout to a stringstrem buffer, but it doesnt' work.

This is the code:

Code:
std::stringstream out;
std::streambuf * old = std::cout.rdbuf();
std::cout.rdbuf(out.rdbuf());
DiJPEGPlugin plugin;
plugin.setQuality(OFstatic_cast(unsigned int, opt_quality));
plugin.setSampling(opt_sampling);
int result = di->writePluginFormat(&plugin, stdout, frameNumber);
std::cout.rdbuf(old);


The result is true, but the size of stringstream is 0.
I'm working under Windows. I think that the stdout is not correctly redirect to my buffer. Is it possible?


Top
 Profile  
 
PostPosted: Fri, 2016-10-28, 19:00 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1956
Location: Oldenburg, Germany
As far as I remember, the standard output stream on Windows does not support binary information very well (or is at least by default not opened in binary mode).

However, there is a define that can be enabled for this purpose. The following excerpt is from "config/docs/macro.txt":
Code:
USE_BINARY_MODE_FOR_STDOUT_ON_WINDOWS
  Affected: dcmdata
  Type of modification: Activates experimental or rarely used feature
  Explanation: On Windows systems, the standard output (stdout) is opened in
    text mode by default.  Therefore, the binary output of tools like dcm2pnm
    to stdout does not work correctly (in contrast to Unix systems).  When
    this preprocessor macro is defined, the binary mode is enabled for stdout.
    However, this causes newlines in the textual output to be converted to LF
    only (instead of CR LF which would be the usual translation for Windows).


My personal opinion is: Don't open "stdout" in binary mode (on Windows).


Top
 Profile  
 
PostPosted: Fri, 2016-10-28, 19:03 
Offline

Joined: Tue, 2008-09-16, 15:02
Posts: 169
So is it possible to make a JPEG to a standard file only? Not in memory?


Top
 Profile  
 
PostPosted: Fri, 2016-10-28, 19:06 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1956
Location: Oldenburg, Germany
I guess this would require you to write a corresponding DiJPEGPlugin::write() method.

When we developed these output plugins, there was no need to create JPEG files in memory. I still see no reason for this.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group