tweaking...

This commit is contained in:
tTh
2023-01-07 10:40:29 +01:00
parent 2f4272909a
commit 8223cb8e77
5 changed files with 38 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
!-
! This module try to write PGM complient gray level files
! This module try to write PNM complient RGB files
!-
module pixrgb
implicit none
@@ -28,6 +28,23 @@ subroutine rgbpix_set_to_zero(pic)
end subroutine
!-------------------------------------------------------------------
!-
! NOT TESTED !!!
!-
subroutine rgb_pix_clamp_at_8(pic)
type(t_pixrgb), intent(inout) :: pic(:,:)
integer :: ix, iy
do iy=1, ubound(pic, 2)
do ix=1, ubound(pic, 1)
pic(ix, iy)%r = max(0, min(pic(ix, iy)%r, 255))
pic(ix, iy)%g = max(0, min(pic(ix, iy)%g, 255))
pic(ix, iy)%b = max(0, min(pic(ix, iy)%b, 255))
enddo
enddo
end subroutine
!-------------------------------------------------------------------
!-
! CAUTION: there was NO out-of-bounds check !
!-
subroutine rgbpix_spit_as_pnm_8(pic, fname)
type(t_pixrgb), intent(in) :: pic(:,:)
character (len=*), intent(in) :: fname
@@ -42,7 +59,7 @@ subroutine rgbpix_spit_as_pnm_8(pic, fname)
do iy=1, ubound(pic, 2)
do ix=1, ubound(pic, 1)
write(io, "(3I12)") pic(ix, iy)%r, pic(ix, iy)%g, pic(ix, iy)%b
write(io, "(3I5)") pic(ix, iy)%r, pic(ix, iy)%g, pic(ix, iy)%b
enddo
enddo
close(unit=io)
@@ -50,6 +67,8 @@ subroutine rgbpix_spit_as_pnm_8(pic, fname)
end subroutine
!-------------------------------------------------------------------
!-
! CAUTION: there was NO out-of-bounds check !
!-
subroutine rgbpix_spit_as_pnm_16(pic, fname)
type(t_pixrgb), intent(in) :: pic(:,:)