@@ -116,6 +116,7 @@ static int cell_draw(char *name,
116
116
void * ptr ;
117
117
int big_endian ;
118
118
long one = 1 ;
119
+ FILE * fo ;
119
120
120
121
big_endian = !(* ((char * )(& one )));
121
122
@@ -132,6 +133,10 @@ static int cell_draw(char *name,
132
133
grn = G_malloc (ncols );
133
134
blu = G_malloc (ncols );
134
135
set = G_malloc (ncols );
136
+
137
+ /* some buggy C libraries require BOTH setmode() and fdopen(bin) ? */
138
+ //setmode(fileno(stdin), O_BINARY);
139
+ fo = fdopen (fileno (stdout ), "wb" );
135
140
136
141
/* loop for array rows */
137
142
for ( row = 0 ; row < nrows ; row ++ ) {
@@ -155,9 +160,9 @@ static int cell_draw(char *name,
155
160
// consider byte order (well, middle endian ignored)
156
161
if ( big_endian ) {
157
162
// I have never tested this
158
- fprintf (stdout , "%c%c%c%c" , alpha , red [i ],grn [i ],blu [i ]);
163
+ fprintf (fo , "%c%c%c%c" , alpha , red [i ],grn [i ],blu [i ]);
159
164
} else {
160
- fprintf (stdout , "%c%c%c%c" , blu [i ],grn [i ],red [i ],alpha );
165
+ fprintf (fo , "%c%c%c%c" , blu [i ],grn [i ],red [i ],alpha );
161
166
}
162
167
}
163
168
}
0 commit comments