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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: reading and writing pgm files [message #3988] Tue, 11 April 1995 00:00
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);
Re: reading and writing pgm files [message #3990 is a reply to message #3988] Tue, 11 April 1995 00:00 Go to previous message
fedor is currently offline  fedor
Messages: 4
Registered: August 1992
Junior Member
In article <3mebvm$bk8@seralph9.essex.ac.uk> Greening C M <greec> writes:
> Does anyone have, or know where to get hold of, code to read and
> write .pgm format image files?.
I assume you mean IDL code? I have a program 'getim.pro' that reads raw format pbm pgm and ppm files - ftp://hopper.colorado.edu/pub/optics/getim.pro

Otherwise you can get the pbmplus package. last I heard it was available at
ftp://export.lcs.mit.edu plus about a million other sites (check graphics
or X11 contribution sites).
--
Adam Fedor. CU, Boulder | Fudd's Law of Opposition: Push something
fedor@boulder.colorado.edu (W) | hard enough and it will fall over.
adam@bastille.rmnug.org (H,NeXTMail)|
  Switch to threaded view of this topic Create a new topic Submit Reply
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: Wed Oct 08 15:47:08 PDT 2025

Total time taken to generate the page: 0.00520 seconds