Q: reading PBM

L

laniik

Hi, I was wondering if anyone knew how to read a pbm binary file (type
P5).

I know how to parse the header, which is ascii:

Format (P5)
# comments possibly
Width Height
Max Value (255)

BITBITBITBITBITBITBITBIT...

so my only question is how I can parse the binary data that comes after
it? Does anyone have any code/know what the format of the binary data
is? Thanks!

(oh, its greyscale if that wasnt clear, with 255 possible values)

Oliver
 
A

Artie Gold

laniik said:
Hi, I was wondering if anyone knew how to read a pbm binary file (type
P5).

I know how to parse the header, which is ascii:

Format (P5)
# comments possibly
Width Height
Max Value (255)

BITBITBITBITBITBITBITBIT...

so my only question is how I can parse the binary data that comes after
it? Does anyone have any code/know what the format of the binary data
is? Thanks!

(oh, its greyscale if that wasnt clear, with 255 possible values)

Oliver
Off topic here. Try http://www.wotsit.org for information about file
formats.

HTH,
--ag
 
L

laniik

thanks. im also asking how to read in binary data at all tho, which
might be more on-topic
 
K

Karl Heinz Buchegger

laniik said:
thanks. im also asking how to read in binary data at all tho, which
might be more on-topic

open file
read data
close file

Which parts give you trouble and are not explained in your book?

Note: In which way the part "read data" needs to be implemented is
entirely dependent on the exact file format and such off topic
here.

As for 'open file': make sure you specify that you want a 'binary open'
as for 'read data': Use the functions get() or read(). There is no way
to sensibly and correctly read binary data with >>
as for 'close data': nothing special to take care of.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top