Skip to content
Permalink
Browse files

force binary mode for stdout

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12896 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek
rblazek committed Feb 7, 2010
1 parent a1b22f5 commit 837059cc4f84c3453381da89dc20648c6283ba2d
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/providers/grass/qgis.d.rast.c
@@ -116,6 +116,7 @@ static int cell_draw(char *name,
void *ptr;
int big_endian;
long one= 1;
FILE *fo;

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

@@ -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++ ) {
@@ -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);
}
}
}

0 comments on commit 837059c

Please sign in to comment.
You can’t perform that action at this time.