comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: reading and writing pgm files
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: reading and writing pgm files [message #3988] Tue, 11 April 1995 00:00 Go to previous message
johnl is currently offline  johnl
Messages: 1
Registered: April 1995
Junior Member
I tried to mail a reply but your posting software didn't
include your mail address.

Greening C M (greec) wrote:
: Does anyone have, or know where to get hold of, code to read and
: write .pgm format image files?.

It is very simple, you really don't need much code.

I assume that you want to read/write PGM files from your
application program. Here are some bits of code I used to
create/write PGM files in one of my programs. The image
is a lineSize*1014 array of 8 bit values. I used the manual
pages from the PBM software to get the file format
specification.

/* open PGM output file */
sprintf(ofName, "SNDR%.4d.PGM", serial);
if ((pgmFile = fopen(ofName, "wb")) == NULL) {
fprintf(stderr, "%s: can't open %s\n", pName, ofName);
exit(1);
}
fprintf(pgmFile, "P5 %d %d %d\n", lineSize, 1014, 255);

/* note: repeated 1014 times to output experiment video */
/* write PGM data */
for (j = 0; j < lineSize; ++j)
putc(255 - lineBuf[j], pgmFile);

/* close PGM file */
fclose(pgmFile);
[Message index]
 
Read Message
Read Message
Previous Topic: IDL Structures - Any Improvement Due?
Next Topic: Reading unformatted data from exabyte tape

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 04:36:44 PDT 2025

Total time taken to generate the page: 1.27865 seconds