tags:

views:

44

answers:

2

Is it possible to create a raw image in Fortran? I was thinking BMP but not really sure what extension would be best.

Basically, I want to be able to have an array or a text file that contains the color values for each pixel, so a 3 pixel wide red image would just be FF0000FF0000FF0000 or something similar to that

+1  A: 

You could use the PPM format. http://en.wikipedia.org/wiki/Netpbm_format

KirarinSnow
That looks exactly like what I was looking for, thank you. Do you know of any way to make ppm into a viewable image file? I would like the program to create the ppm file, but have the user be able to open it in a image viewer program, to see the actual picture.
Anthony
PPM can be viewed in a lot of applications. You can also use a program like `convert` (http://www.imagemagick.org/) to turn it into other formats like PNG, etc., which take up less space.
KirarinSnow
A: 

Aspect 1: you have to know the format of the image file. Then you write that format. Likely any standard image files (PPM, BPM, TIFF,...) will include some sort of header. This is inherent in writing a standard image file, independent of the language.

Aspect 2: Fortran 2 used to be relentlessly record oriented, even for unformated (binary) files, which didn't "play" nicely with files written by other languages such as C, or file formats specified without the record deliminators expected by Fortran. But the new Stream I/O method produces non-record files. An image file will be unformatted (binary), so in the open statement include:

access='stream', form='unformatted', ....
M. S. B.