cleanup + add a 0 func
This commit is contained in:
parent
ab601629e5
commit
8ea11d110b
@ -18,6 +18,8 @@ program chkpixels
|
||||
|
||||
contains
|
||||
!-------------------------------------------------------------------
|
||||
!-
|
||||
! exerciser for the 'pixrgb' module
|
||||
!-
|
||||
subroutine test_spit_rgb(sz)
|
||||
integer, intent(in) :: sz
|
||||
@ -27,20 +29,15 @@ contains
|
||||
|
||||
print *, "test spit rgb", sz
|
||||
allocate(pixrgb(sz, sz))
|
||||
! pixrgb = 0
|
||||
|
||||
call rgbpix_set_to_zero(pixrgb)
|
||||
do ix=1, sz
|
||||
do iy=1, sz
|
||||
|
||||
pixrgb(ix, iy)%r = ix
|
||||
pixrgb(ix, iy)%g = 0
|
||||
pixrgb(ix, iy)%b = iy
|
||||
|
||||
end do
|
||||
end do
|
||||
|
||||
call rgbpix_spit_as_pnm_8(pixrgb, "rgb.pnm")
|
||||
|
||||
deallocate(pixrgb)
|
||||
|
||||
end subroutine
|
||||
@ -60,12 +57,10 @@ contains
|
||||
value = value + increment
|
||||
enddo
|
||||
enddo
|
||||
|
||||
call spit_as_pgm_16 (greymap, 'a.pgm')
|
||||
call spit_as_pgm_eq (greymap, 'b.pgm')
|
||||
call spit_as_pgm_8 (greymap, 'c.pgm')
|
||||
call new_spit_a (greymap, 'x.pgm')
|
||||
|
||||
end subroutine
|
||||
|
||||
end program
|
||||
|
@ -15,8 +15,20 @@ end type
|
||||
contains
|
||||
!-------------------------------------------------------------------
|
||||
!-
|
||||
subroutine rgbpix_set_to_zero(pic)
|
||||
type(t_pixrgb), intent(out) :: pic(:,:)
|
||||
integer :: ix, iy
|
||||
do iy=1, ubound(pic, 2)
|
||||
do ix=1, ubound(pic, 1)
|
||||
pic(ix, iy)%r = 0
|
||||
pic(ix, iy)%g = 0
|
||||
pic(ix, iy)%b = 0
|
||||
enddo
|
||||
enddo
|
||||
end subroutine
|
||||
!-------------------------------------------------------------------
|
||||
!-
|
||||
subroutine rgbpix_spit_as_pnm_8(pic, fname)
|
||||
|
||||
type(t_pixrgb), intent(in) :: pic(:,:)
|
||||
character (len=*), intent(in) :: fname
|
||||
|
||||
@ -25,14 +37,12 @@ subroutine rgbpix_spit_as_pnm_8(pic, fname)
|
||||
open(newunit=io, file=fname)
|
||||
write (io, '(a2)') "P3"
|
||||
write (io, '("# rgbpix_spit_as_pnm_8")')
|
||||
write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2)
|
||||
write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2)
|
||||
write (io, '(i0)') 255
|
||||
|
||||
do iy=1, ubound(pic, 2)
|
||||
do ix=1, ubound(pic, 1)
|
||||
|
||||
write(io, "(3I4)") pic(ix, iy)%r, pic(ix, iy)%g, pic(ix, iy)%b
|
||||
|
||||
write(io, "(3I12)") pic(ix, iy)%r, pic(ix, iy)%g, pic(ix, iy)%b
|
||||
enddo
|
||||
enddo
|
||||
close(unit=io)
|
||||
@ -55,9 +65,7 @@ subroutine rgbpix_spit_as_pnm_16(pic, fname)
|
||||
|
||||
do iy=1, ubound(pic, 2)
|
||||
do ix=1, ubound(pic, 1)
|
||||
|
||||
write(io, "(3I6)") pic(ix, iy)%r, pic(ix, iy)%g, pic(ix, iy)%b
|
||||
|
||||
write(io, "(3I6)") pic(ix, iy)%r, pic(ix, iy)%g, pic(ix, iy)%b
|
||||
enddo
|
||||
enddo
|
||||
close(unit=io)
|
||||
|
Loading…
Reference in New Issue
Block a user