📄 write_image.c
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -