Number: 21
Title: Win32 dot version 1.7c can't write binary output to stdout ?
Submitter: David Boreham
Date: Thu Jun 7 16:08:16 2001
Subsys: Dot
Version: 1.7c
System: x86-Other-Win2k SP2
Severity: minor
Problem:
I'm spawning dot to render graphs for me from inside Java servlet-resident code. All is well, except than when I sucked the PNG binary output from the dot process into memory and subsequently sent it to the HTTP client, it didn't display.

Upon investigation I discovered that if I run dot two ways, thus:

dot -Tpng -o foo.png bar.dot

and

dot -Tpng bar.dot > baz.png

then foo.png and baz.png are different !

And baz.png is the same as my version I get from the spawned process.

Looking at the data, I think I see x0a translated to x0ax0d.

So...my theory is that the stdout file needs to be set to binary mode (someone familiar with Win32 will know about the evil binary/text mode fiasco) when the data type is a binary one (e.g. PNG, JPEG).

I looked at the source code and can't see any place where the file mode is set. But fear and loathing of the build environment prevents me from trying a fix myself just yet.

For now I've hacked my code to sent the image to a file which I then read back into memory.

Thanks in advance for your help. Fantastic piece of software, BTW.
Input:

Any valid input.
Fix:
Same as this one I suspect: http://www.ee.ethz.ch/~slist/rrd-developers/msg00381.html
Owner: north
Status: Fixed