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 $@
noisepic: noisepic.f90 Makefile
gfortran $(GFOPT) $< ../Modules/spitpgm.o -o $@
gfortran $(GFOPT) $< ../Modules/spitpgm.o ../Modules/pixrgb.o \
-o $@
# ---- modules locaux

View File

@ -1,6 +1,7 @@
program noisepic
use spitpgm
use pixrgb
implicit none
integer :: numframe = 0
@ -16,12 +17,15 @@ program noisepic
read (arg, *) numframe
endif
call make_noise_pic(numframe)
call make_noise_color_pic(numframe)
contains
!-- ------------------------------------------------------------------
subroutine make_noise_pic (value)
!-
!- Black & White
!-
subroutine make_noise_bw_pic (value)
implicit none
integer, intent(in) :: value
integer :: foo
@ -30,20 +34,20 @@ subroutine make_noise_pic (value)
allocate(pic(320, 240))
pic = 0
pic = 30 !- clear the picz
call srand(value+34)
foo = irand()
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"
call spit_as_pgm_8(pic, trim(filename))
end subroutine
!-- ------------------------------------------------------------------
subroutine plot_noise_pic(picz, nbre)
subroutine plot_noise_bw_pic(picz, nbre)
implicit none
integer, dimension(:,:), intent(inout) :: picz
integer, intent(in) :: nbre
@ -51,23 +55,63 @@ subroutine plot_noise_pic(picz, nbre)
integer :: width, height
integer :: quux, ix, iy, iv
width = ubound(picz, 1) ; height = ubound(picz, 2)
! print *, 'sz picz', width, height
do quux=1, nbre
ix = 1 + mod ( irand(), width )
iy = 1 + mod ( irand(), height )
iv = mod ( irand(), 256 )
! print *, ix, iy
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
end subroutine
!-- ------------------------------------------------------------------
end program