This commit is contained in:
tTh 2022-11-30 02:31:43 +01:00
parent 4d5f38a933
commit fa8b28daae
1 changed files with 6 additions and 3 deletions

View File

@ -1,6 +1,6 @@
!- !-
! This module try to write PNM complient files - ymmv ! This module try to write PNM complient files - ymmv
! !-
module spitpgm module spitpgm
implicit none implicit none
@ -46,6 +46,9 @@ subroutine spit_as_pgm_eq(pic, fname)
end subroutine end subroutine
!------------------------------------------------------------------- !-------------------------------------------------------------------
!-
! 16 bits - 65535 levels portable grey map file
!-
subroutine spit_as_pgm_16(pic, fname) subroutine spit_as_pgm_16(pic, fname)
integer, intent(in), dimension (:,:) :: pic integer, intent(in), dimension (:,:) :: pic
character (len=*), intent(in) :: fname character (len=*), intent(in) :: fname
@ -56,12 +59,12 @@ subroutine spit_as_pgm_16(pic, fname)
open(newunit=io, file=fname) open(newunit=io, file=fname)
write (io, '(a2)') "P2" write (io, '(a2)') "P2"
write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2) write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2)
write (io, '(i0)') 255 write (io, '(i0)') 65535
do iy=1,ubound(pic, 2) do iy=1,ubound(pic, 2)
do ix=1, ubound(pic, 1) do ix=1, ubound(pic, 1)
foo = pic(ix, iy) foo = pic(ix, iy)
if (foo .GT. 65535) foo = 65530 if (foo .GT. 65535) foo = 65530
write(io, "(i3)") foo write(io, "(i5)") foo
enddo enddo
enddo enddo
close(io) close(io)