print_p3(3f) - [M_pixel:PRINT] print pixel array as a ppm p3 file
(LICENSE:PD)
definition:
subroutine print_p3(filename)
character(len=*),intent(in) :: filename
This driver makes an ASCII P3 portable pixmap file. Any existing file is replaced.
FILENAME name of output file to create or replace
Sample program:
program demo_print_p3
use M_pixel, only : prefsize,vinit,ortho2,vexit
use M_pixel, only : linewidth,circle,color
use M_pixel, only : print_p3
implicit none
call prefsize(40,40)
call vinit()
call ortho2(-100.0,100.0,-100.0,100.0)
call linewidth(400)
call circle(0.0,0.0,45.0)
call color(3)
call circle(0.0,0.0,25.0)
call print_p3('demo_print.p3')
call vexit()
end program demo_print_p3
John S. Urban
Public Domain
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filename |
subroutine print_p3(filename)
! ident_38="@(#) M_pixel print_p3(3f) print pixel array as a P3 PPM file"
character(len=*),intent(in) :: filename
integer :: iu,ios,i,xs,ys,cs
character(len=4096) :: message
open(file=trim(filename),newunit=iu,iostat=ios,iomsg=message,action='write')
if(ios.eq.0)then
call if_init()
xs=size(P_pixel,dim=1)
ys=size(P_pixel,dim=2)
cs=size(P_ColorMap,dim=2)
write(iu,'("P3",/,i0,1x,i0,/,i0,/,(20(i0,1x)))') xs,ys,cs,((P_ColorMap(1:3,P_pixel(i,j)),i=0,xs-1),j=0,ys-1)
else
write(*,*)'*P_print_p3* ERROR: ',trim(message)
endif
flush(unit=iu,iostat=ios)
close(unit=iu,iostat=ios)
end subroutine print_p3