Johannes, you may try something like this - I send it in two posts due to the known limitations:
winapp
program test
implicit none
include <windows.ins>
integer*2 dummy,handle
integer*4 i,j,A,B,C,lins,cols,c_eff
character*1 image(1000000)
character*1 buffer(100000)
c create binary test image (replace by your own)
lins = 1000
cols = 1000
do i = 1,lins
A = (i-1)*cols
do j = 1,cols
if (mod(i,50) .eq. 0 .or. mod(j,50) .eq. 0) then
image(A+j) = char(1)
else
image(A+j) = char(0)
end if
end do
end do
c open BMP file
call openw@('test.bmp',handle,dummy)
if (dummy .ne. 0) goto 999
call w_bmp_head(lins,cols,c_eff,buffer)
call writef@(buffer,handle,1078L,dummy)
if (dummy .ne. 0) goto 999
c write image to BMP file
do i = 1,lins
A = (i-1)*cols
C = 0
buffer = char(0)
do j = 1,cols,8
B = 128*ichar(image(A+j ))+64*ichar(image(A+j+1))+
* 32*ichar(image(A+j+2))+16*ichar(image(A+j+3))+
* 8*ichar(image(A+j+4))+ 4*ichar(image(A+j+5))+
* 2*ichar(image(A+j+6))+ ichar(image(A+j+7))
C = C+1
buffer(C) = char(B)
end do
call writef@(buffer,handle,c_eff,dummy)
if (dummy .ne. 0) goto 999
end do
999 call closef@(handle,dummy)
end