write_image.c

来自「shpf 1.9一个并行编译器」· C语言 代码 · 共 40 行

C
40
字号

#include "stdio.h"

#include "ad++.h"
#include "admacros.h"

void write_image(char* filename, Array2<int> image,
                 int nx, int ny, int maxin) {

// _____________________________________________________________________
//|                                                                     |
//| Subroutine, to write a .pgm format file, from an integer array.     |
//|                                                                     |
//| H W Yau.  14th of February, 1994.                                   |
//| Northeast Parallel Architectures Center.                            |
//| Syracuse University.                                                |
//|_____________________________________________________________________|
//|                                                                     |
//| Edit record:                                                        |
//| 14/Feb/1995: Copied from Guy and Ken's wavelet code.  Hon-ie-fied.  |
//|_____________________________________________________________________|

// .. Local variables ..

  Range i = image.rng(0), j = image.rng(1) ;

// Write out image into file.

  gprintf("Writing image %s of size %6d by %6d pixels Max intensity = %6d\n",
          filename, nx, ny, maxin) ;

  FILE* ifile = gfopen(filename, "w") ;

  gfprintf(ifile, "P2\n%d %d\n%d\n", nx, ny, maxin) ;
  afprintf(ifile, "%4d%16N", image.sect(i.sub(nx, 0), j.sub(ny, 0))) ;

  gfclose(ifile) ;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?