]> Pileus Git - ~andy/rsl/blobdiff - src/image_gen.c
Open files in binary mode for Win32
[~andy/rsl] / src / image_gen.c
index ba968c2413b606809ca17d871e267333f479b1c7..3c69b7b34966e095dab775bbe624ee09ae9f08d8 100644 (file)
@@ -82,7 +82,7 @@ void RSL_load_color_table(char *infile, char buffer[256], int *num_colors)
 {
   FILE *fp;
 
-  fp = fopen(infile, "r");
+  fp = fopen(infile, "rb");
   if (fp == NULL) {
        perror(infile);
        exit(-1);
@@ -290,7 +290,7 @@ void RSL_bscan_sweep(Sweep *s, char *outfile)
   FILE *fp;
   if (s == NULL) return;
   
-  fp = fopen(outfile,"w");
+  fp = fopen(outfile,"wb");
   if (fp == NULL) {
        perror(outfile);
        return;
@@ -522,7 +522,7 @@ void RSL_write_gif(char *outfile, unsigned char *image, int xdim, int ydim, char
   fpipe = NULL;
   nbytes = xdim*ydim;
   (void)sprintf(pipecmd, "ppmtogif > %s 2>/dev/null", outfile);
-  fpipe = popen(pipecmd, "w");  /* Global FILE * */
+  fpipe = popen(pipecmd, "wb");  /* Global FILE * */
   if (fpipe == NULL) {
        perror("RSL_write_gif1");
        return;
@@ -563,7 +563,7 @@ void RSL_write_pict(char *outfile, unsigned char *image, int xdim, int ydim, cha
   }
   nbytes = xdim*ydim;
   (void)sprintf(pipecmd, "ppmtopict > %s 2>/dev/null", outfile);
-  fpipe = popen(pipecmd, "w");  /* Global FILE * */
+  fpipe = popen(pipecmd, "wb");  /* Global FILE * */
   fprintf(fpipe, "P6\n# %s\n%d %d\n255\n",outfile, xdim, ydim);
   for (i=0; i<nbytes; i++)
          if (fwrite(c_table[image[i]], sizeof(char), 3, fpipe) != 3)
@@ -589,7 +589,7 @@ void RSL_write_ppm(char *outfile, unsigned char *image, int xdim, int ydim, char
     return;
   }
   nbytes = xdim*ydim;
-  fpipe = fopen(outfile, "w");  /* Global FILE * */
+  fpipe = fopen(outfile, "wb");  /* Global FILE * */
   fprintf(fpipe, "P6\n# %s\n%d %d\n255\n",outfile, xdim, ydim);
   for (i=0; i<nbytes; i++)
          if (fwrite(c_table[image[i]], sizeof(char), 3, fpipe) != 3)
@@ -616,7 +616,7 @@ void RSL_write_pgm(char *outfile, unsigned char *image, int xdim, int ydim)
   }
   nbytes = xdim*ydim;
   (void)sprintf(pipecmd, "gzip > %s.gz 2>/dev/null", outfile);
-  fpipe = popen(pipecmd, "w");  /* Global FILE * */
+  fpipe = popen(pipecmd, "wb");  /* Global FILE * */
   fprintf(fpipe, "P5\n# %s\n%d %d\n255\n",outfile, xdim, ydim);
   if (fwrite(image, sizeof(char), nbytes, fpipe) != nbytes)
        fprintf(stderr, "RSL_write_pgm: short write\n");
@@ -625,7 +625,7 @@ void RSL_write_pgm(char *outfile, unsigned char *image, int xdim, int ydim)
 /*  The following is commented and is for non compressed. */
 #ifdef COMPILE
   nbytes = xdim*ydim;
-  fpipe = fopen(outfile, "w");  /* Global FILE * */
+  fpipe = fopen(outfile, "wb");  /* Global FILE * */
   fprintf(fpipe, "P5\n# %s\n%d %d\n255\n",outfile, xdim, ydim);
   (void)fwrite(image, sizeof(char), nbytes, fpipe);
   (void)fclose(fpipe);