Thank you Paul for your answer. I looked at Clearwin+ and found some hints for importing my bmp file in a window. However, the problem now is that I cannot read the colour of the pixels in my image. This is a short version of my program
Program Imagine
USE MSWIN
implicit none
CHARACTER*50 file
CHARACTER a(3,1024,1024)
INTEGER hres,vres,nb_colours,ier,i,k,control,red,white,black,j,green
integer colour1,colour2,colour3
type coordenate
integer x
integer y
end type coordenate
type(coordenate),dimension(:),allocatable :: matrix
file='c:\imagen640.bmp'
CALL set_rgb_colours_default@(1)
CALL get_dib_size@(file,hres,vres,nb_colours,ier)
IF(ier.NE.0.OR.hres.GT.1024.OR.vres.GT.1024) STOP 'TROUBLE: file not found'
CALL get_dib_block@(file,a,1024,1024,0,0,hres,vres,0,0,ier)
IF(ier.NE.0) STOP 'TROUBLE'
allocate(matrix(hres*vres))
k=1
i=winio@('%gr%lw',hres,vres,control)
CALL display_dib_block@(0,0,a,1024,1024,0,0,hres,vres,0,0,ier)
red= get_matched_colour@(RGB@(255,0,0))
black=get_matched_colour@(RGB@(0,0,0))
white=get_matched_colour@(RGB@(255,255,255))
green=get_matched_colour@(RGB@(0,255,0))
! check the bitmap to find the limits of the black figure on a white background
! the limiting point are saved in an array for plotting latter
DO i=1,hres
do j=1,vres
CALL get_rgb_value@(i,j,colour1)
CALL get_rgb_value@(i,j-1,colour2)
CALL get_rgb_value@(i,j+1,colour3)
if(colour1 == black.and.colour2 /= black.and.colour3 ==black) then
matrix(k)%x=i; matrix(k)%y=j
k=k+1
call draw_point@(i,j,red)
elseif(colour1 == black.and.colour2 == black.and.colour3 /= black) then
matrix(k)%x=i; matrix(k)%y=j
k=k+1
call draw_point@(i,j,red)
else
call draw_point@(i,j,green)
endif
END DO
end do
open(87,file='c:\entorno')
do i=1,k
write (87,*) matrix(i)%x, matrix(i)%y
end do
close(87)
!c--- Write the image away to another file
file='c:\temp\junk.bmp'
CALL put_dib_block@(file,a,1024,1024,0,0,hres,vres,24,ier)
END
The idea is to sweep the image along the pixels and check if the pixel is black or white and if it is in the border of the figure (i.e. for instance, the pixel at the border should be black but the previous should also be black and the next should be white if you are leaving the figure or the previous should be white and the next black if you are entering into the figure). For this purpose I call the subroutine CALL get_rgb_value@ and change the colour of the pixel to red if I am in the border (just for marking the border). However, what I get is the same whole figure in red instead of black! Am I misunderstanding the meaning of the subroutine CALL get_rgb_value@?. Any clue would be greatly appreciated!!
Thanks a lot!
Agustin