On 27 Aug 2005 14:31:55 -0700, "George" <bu*******@hotmail.com> wrote
in comp.lang.c:
I am lost on how to do this. I have not worked with C much at all but
can understand the basic properties of this language. Could someone
please show me or explain to me how to write a function that outputs
ASCII PPM files. I need to output a 512 x 512 image containing random
noise with the top-most row of pixels red and the left-most pixels
blue( instead of the random). Thank you so much for your help it will
greatly greatly be appreciated and it will allow me to understand this
type of format a lot more. Again thanks.
Your request is not very clear. You have posted a statement of what
it is that you have to do, but you haven't identified the part that it
causing you a problem. You have also used an abbreviation or acronym,
"PPM", that you haven't identified, apparently because you assume
everyone knows what it means.
Assuming that your system uses the ASCII character set, which is not
required by C but almost a certainly, the most convenient way to
generate a text (ASCII) file is to use the fopen() function with a
mode argument of "w". The easiest way to write text data to such a
file is to use the fprintf() function.
On the other hand, if your problem is with generating the image data,
that's not really C related at all, although the srand() and rand()
functions can be helpful in generating "white noise" or "random" data.
Finally if you don't understand the format of the image or the output
file, that's not a C language issue at all. You need to do some
research.
http://www.wotsit.org is an excellent site to look for the
format of many different types of files.
And of course, there's Google.
When I did a Google search for the phrase "ASCII PPM" I found a large
number of hits. Interestingly enough, some of the links appeared to
be homework assignments for CS classes. People here are not willing
to do someone's homework assignment for them, although they are
willing to help.
If you understand how to generate your data and the file format, but
you have a problem writing correct code to work in C, then post the
problem code here and explain your problem with it, and people will be
happy to offer advice.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html