Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,23 @@
# Convert color image (PPM) to greyscale image (PGM)
(de ppm->pgm (Ppm)
(mapcar
'((Y)
(mapcar
'((C)
(/
(+
(* (car C) 2126) # Red
(* (cadr C) 7152) # Green
(* (caddr C) 722) ) # Blue
10000 ) )
Y ) )
Ppm ) )
# Convert greyscale image (PGM) to color image (PPM)
(de pgm->ppm (Pgm)
(mapcar
'((Y)
(mapcar
'((G) (list G G G))
Y ) )
Pgm ) )

View file

@ -0,0 +1,26 @@
# Write greyscale image (PGM) to file
(de pgmWrite (Pgm File)
(out File
(prinl "P5")
(prinl (length (car Pgm)) " " (length Pgm))
(prinl 255)
(for Y Pgm (apply wr Y)) ) )
# Create an empty image of 120 x 90 pixels
(setq *Ppm (make (do 90 (link (need 120)))))
# Fill background with green color
(ppmFill *Ppm 0 255 0)
# Draw a diagonal line
(for I 80 (ppmSetPixel *Ppm I I 0 0 0))
# Convert to greyscale image (PGM)
(setq *Pgm (ppm->pgm *Ppm))
# Write greyscale image to .pgm file
(pgmWrite *Pgm "img.pgm")
# Convert to color image and write to .ppm file
(ppmWrite (pgm->ppm *Pgm) "img.ppm")