color mode for noisepic

This commit is contained in:
tTh 2023-05-07 20:23:33 +02:00
parent aace571169
commit 9366c67c4b
2 changed files with 57 additions and 12 deletions

View File

@ -21,7 +21,8 @@ trigofest: trigofest.f90 Makefile vue3axes.o utils_ga.o
utils_ga.o -o $@ utils_ga.o -o $@
noisepic: noisepic.f90 Makefile noisepic: noisepic.f90 Makefile
gfortran $(GFOPT) $< ../Modules/spitpgm.o -o $@ gfortran $(GFOPT) $< ../Modules/spitpgm.o ../Modules/pixrgb.o \
-o $@
# ---- modules locaux # ---- modules locaux

View File

@ -1,6 +1,7 @@
program noisepic program noisepic
use spitpgm use spitpgm
use pixrgb
implicit none implicit none
integer :: numframe = 0 integer :: numframe = 0
@ -16,12 +17,15 @@ program noisepic
read (arg, *) numframe read (arg, *) numframe
endif endif
call make_noise_pic(numframe) call make_noise_color_pic(numframe)
contains contains
!-- ------------------------------------------------------------------ !-- ------------------------------------------------------------------
subroutine make_noise_pic (value) !-
!- Black & White
!-
subroutine make_noise_bw_pic (value)
implicit none
integer, intent(in) :: value integer, intent(in) :: value
integer :: foo integer :: foo
@ -30,20 +34,20 @@ subroutine make_noise_pic (value)
allocate(pic(320, 240)) allocate(pic(320, 240))
pic = 0 pic = 30 !- clear the picz
call srand(value+34) call srand(value+34)
foo = irand() foo = irand()
print *, 'val=', value, ' rnd=', foo print *, 'val=', value, ' rnd=', foo
call plot_noise_pic(pic, 15000) call plot_noise_bw_pic(pic, 15000)
write (filename, "(a, i5.5, a)") "", value, ".pgm" write (filename, "(a, i5.5, a)") "", value, ".pgm"
call spit_as_pgm_8(pic, trim(filename)) call spit_as_pgm_8(pic, trim(filename))
end subroutine end subroutine
!-- ------------------------------------------------------------------ !-- ------------------------------------------------------------------
subroutine plot_noise_pic(picz, nbre) subroutine plot_noise_bw_pic(picz, nbre)
implicit none
integer, dimension(:,:), intent(inout) :: picz integer, dimension(:,:), intent(inout) :: picz
integer, intent(in) :: nbre integer, intent(in) :: nbre
@ -51,23 +55,63 @@ subroutine plot_noise_pic(picz, nbre)
integer :: width, height integer :: width, height
integer :: quux, ix, iy, iv integer :: quux, ix, iy, iv
width = ubound(picz, 1) ; height = ubound(picz, 2) width = ubound(picz, 1) ; height = ubound(picz, 2)
! print *, 'sz picz', width, height ! print *, 'sz picz', width, height
do quux=1, nbre do quux=1, nbre
ix = 1 + mod ( irand(), width ) ix = 1 + mod ( irand(), width )
iy = 1 + mod ( irand(), height ) iy = 1 + mod ( irand(), height )
iv = mod ( irand(), 256 ) iv = mod ( irand(), 256 )
! print *, ix, iy ! print *, ix, iy
picz(ix, iy) = iv picz(ix, iy) = iv
enddo
end subroutine
!-- ------------------------------------------------------------------
!-
!- Colorized
!-
subroutine make_noise_color_pic (value)
implicit none
integer, intent(in) :: value
integer :: foo
type(t_pixrgb), dimension(:,:), allocatable :: pix
character (len=280) :: filename
allocate(pix(320, 240))
call rgbpix_set_to_rgb(pix, 30, 30, 60)
call srand(value+34)
foo = irand()
print *, 'val=', value, ' rnd=', foo
call plot_noise_color_pic(pix, 15000)
write (filename, "(a, i5.5, a)") "./", value, ".pnm"
call rgbpix_spit_as_pnm_8(pix, trim(filename))
end subroutine
!-- ------------------------------------------------------------------
subroutine plot_noise_color_pic(prgb, nbre)
implicit none
type(t_pixrgb), dimension(:,:), intent(inout) :: prgb
integer, intent(in) :: nbre
integer :: quux, ix, iy, width, height
width = ubound(prgb, 1) ; height = ubound(prgb, 2)
do quux=1, nbre
ix = 1 + mod ( irand(), width )
iy = 1 + mod ( irand(), height )
prgb(ix, iy)%r = 64 + mod ( irand(), 127 )
prgb(ix, iy)%g = 64 + mod ( irand(), 127 )
prgb(ix, iy)%b = 64 + mod ( irand(), 127 )
enddo enddo
end subroutine end subroutine
!-- ------------------------------------------------------------------ !-- ------------------------------------------------------------------
end program end program