Skip to content

Commit

Permalink
force binary mode for stdout
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12896 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Feb 7, 2010
1 parent f4acc04 commit 71f1842
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/providers/grass/qgis.d.rast.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ static int cell_draw(char *name,
void *ptr;
int big_endian;
long one= 1;
FILE *fo;

big_endian = !(*((char *)(&one)));

Expand All @@ -132,6 +133,10 @@ static int cell_draw(char *name,
grn = G_malloc(ncols);
blu = G_malloc(ncols);
set = G_malloc(ncols);

/* some buggy C libraries require BOTH setmode() and fdopen(bin) ? */
//setmode(fileno(stdin), O_BINARY);
fo = fdopen (fileno(stdout), "wb");

/* loop for array rows */
for ( row = 0; row < nrows; row++ ) {
Expand All @@ -155,9 +160,9 @@ static int cell_draw(char *name,
// consider byte order (well, middle endian ignored)
if ( big_endian ) {
// I have never tested this
fprintf(stdout, "%c%c%c%c", alpha, red[i],grn[i],blu[i]);
fprintf(fo, "%c%c%c%c", alpha, red[i],grn[i],blu[i]);
} else {
fprintf(stdout, "%c%c%c%c", blu[i],grn[i],red[i],alpha);
fprintf(fo, "%c%c%c%c", blu[i],grn[i],red[i],alpha);
}
}
}
Expand Down

0 comments on commit 71f1842

Please sign in to comment.