*.pgm的图象文件用什么工具看?文件格式什么书上有啊?(50分)

  • 主题发起人 主题发起人 luomingxue
  • 开始时间 开始时间
L

luomingxue

Unregistered / Unconfirmed
GUEST, unregistred user!
有人用程序读过吗?
 
不知道是不是这个:

pgm(5) FILE FORMATS pgm(5)



NAME
pgm - portable graymap file format

DESCRIPTION
The portable graymap format is a lowest common denominator
grayscale file format. The definition is as follows:

- A "magic number" for identifying the file type. A pgm
file's magic number is the two characters "P2".

- Whitespace (blanks, TABs, CRs, LFs).

- A width, formatted as ASCII characters in decimal.

- Whitespace.

- A height, again in ASCII decimal.

- Whitespace.

- The maximum gray value, again in ASCII decimal.

- Whitespace.

- Width * height gray values, each in ASCII decimal, between
0 and the specified maximum value, separated by whi-
tespace, starting at the top-left corner of the graymap,
proceeding in normal English reading order. A value of 0
means black, and the maximum value means white.

- Characters from a "#" to the next end-of-line are ignored
(comments).

- No line should be longer than 70 characters.

Here is an example of a small graymap in this format:
P2
# feep.pgm
24 7
15
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0
0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0
0 3 3 3 0 0 0 7 7 7 0 0 0 11 11 11 0 0 0 15 15 15 15 0
0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0
0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Programs that read this format should be as lenient as pos-
sible, accepting anything that looks remotely like a gray-
map.

There is also a variant on the format, available by setting
the RAWBITS option at compile time. This variant is dif-
ferent in the following ways:

- The "magic number" is "P5" instead of "P2".

- The gray values are stored as plain bytes, instead of
ASCII decimal.

- No whitespace is allowed in the grays section, and only a
single character of whitespace (typically a newline) is
allowed after the maxval.

- The files are smaller and many times faster to read and
write.

Note that this raw format can only be used for maxvals less
than or equal to 255. If you use the _p_g_m library and try to
write a file with a larger maxval, it will automatically
fall back on the slower but more general plain format.

AUTHOR
Copyright (C) 1989, 1991 by Jef Poskanzer.
 
JPEG 6a里面有一个rdppm.c可以读PPM/PGM格式的文件。
类似的源代码还是很多的,用搜索引擎上网找一下就可以
发现一大堆。infoseek.go.com是比较好的搜索引擎。
/*
* rdppm.c
*
* Copyright (C) 1991-1997, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains routines to read input images in PPM/PGM format.
* The extended 2-byte-per-sample raw PPM/PGM formats are supported.
* The PBMPLUS library is NOT required to compile this software
* (but it is highly useful as a set of PPM image manipulation programs).
*
* These routines may need modification for non-Unix environments or
* specialized applications. As they stand, they assume input from
* an ordinary stdio stream. They further assume that reading begins
* at the start of the file; start_input may need work if the
* user interface has already read some data (e.g., to determine that
* the file is indeed PPM format).
*/

 
icee.seu.edu.cn 的程序员大本营,里有个文件格式大本营,不知道对你有没有用!!
 
接受答案了.
 
后退
顶部