Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fortran / reading a header of a binary file and write into it

Status
Not open for further replies.

mredjlali

Programmer
Mar 15, 2003
2
CA
Hi,
Does anyone know how to read h and v stored in byte 19 and 20 for h and 23 and 24 for v in a header of a 24-bit colour BMP file. Header has 54 bytes and overall size is 3hv+54.
Also how can I write some words into a binary file for example writing "fortran" into the withe box of at the right upper corner of 600*300 bitmap image without chnging the header? My system support fort77.
Thanks
 
The problem is actually how you open the file. Different versions of f77 behave differently. With g77, the following will work

open (unit, file, status='old', access = 'direct', form = 'unformatted', recl = 1)

There is a sample program in which writes bmp files. The sample does 2, 4 and 8 bit colour: not 24 as you requested but basically it is just playing about with the header definition to get it to work. Also note that the bitmap is stored upside down.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top