~nytpu/autostereogramify

64cae3719bec3ff5a9e750e0548abd178995077c — nytpu 7 months ago c97da94 master
updaet
4 files changed, 23 insertions(+), 21 deletions(-)

M .editorconfig
M src/autostereogramify.lisp
M src/main.lisp
M src/package.lisp
M .editorconfig => .editorconfig +2 -0
@@ 6,6 6,8 @@ end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8

[*.{lisp,asd}]
indent_style = space
indent_size = 2


M src/autostereogramify.lisp => src/autostereogramify.lisp +10 -10
@@ 28,9 28,9 @@
  (etypecase image
    ((or opticl:8-bit-rgb-image
         opticl:8-bit-rgba-image)
     (bind ((:with opticl:with-image-bounds (height width) image)
            (out (opticl:make-8-bit-gray-image height width)))
       (opticl:set-pixels (y x) out
     (bind* ((:with opticl:with-image-bounds (height width) image)
             (out (opticl:make-8-bit-gray-image height width)))
            (opticl:set-pixels (y x) out
         (multiple-value-bind (r g b) (opticl:pixel image y x)
           (declare (type (unsigned-byte 8) r g b))
           (rgb->gray r g b)))


@@ 46,8 46,8 @@
         opticl:8-bit-rgba-image)
     image)
    ((or opticl:8-bit-gray-image opticl:8-bit-gray-alpha-image)
     (bind ((:with opticl:with-image-bounds (height width) image)
            (out (opticl:make-8-bit-rgb-image height width)))
     (bind* ((:with opticl:with-image-bounds (height width) image)
             (out (opticl:make-8-bit-rgb-image height width)))
       (opticl:set-pixels (y x) out
         (gray->rgb (opticl:pixel image y x)))
       out))))


@@ 93,11 93,11 @@ If WIDTH-OVERRIDE is given a number, then that will be used as the tiling width 
           (type opticl:8-bit-rgb-image tile)
           (type boolean random grayscale invert)
           (type (or fixnum null) width-override))
  (bind ((:with opticl:with-image-bounds (height width) depth-mask)
         (out (opticl:make-8-bit-rgb-image height width))
         (:with opticl:with-image-bounds (tile-height tile-width) tile)
         (tile-width (if width-override (min width-override tile-width) tile-width))
         (depth-lookup (create-depth-lut tile-width invert)))
  (bind* ((:with opticl:with-image-bounds (height width) depth-mask)
          (out (opticl:make-8-bit-rgb-image height width))
          (:with opticl:with-image-bounds (tile-height tile-width) tile)
          (tile-width (if width-override (min width-override tile-width) tile-width))
          (depth-lookup (create-depth-lut tile-width invert)))
    (declare (type fixnum height width tile-height tile-width)
             (type vector depth-lookup))
    (loop for y fixnum below height

M src/main.lisp => src/main.lisp +10 -10
@@ 71,11 71,11 @@
    (print-usage-and-exit cmd :code 0))
  (when (clingon:getopt cmd :version)
    (clingon:print-version-and-exit cmd *error-output*))
  (bind ((random-tile (clingon:getopt cmd :random-tile))
         (tile-width (clingon:getopt cmd :tile-width))
         (grayscale (clingon:getopt cmd :grayscale))
         (args (clingon:command-arguments cmd))
         (length (length args)))
  (bind* ((random-tile (clingon:getopt cmd :random-tile))
          (tile-width (clingon:getopt cmd :tile-width))
          (grayscale (clingon:getopt cmd :grayscale))
          (args (clingon:command-arguments cmd))
          (length (length args)))
    (when (and random-tile (not tile-width))
      (print-usage-and-exit cmd :prefix-message "Tile width not provided when using random background."))
    (cond


@@ 90,11 90,11 @@
      ((> length 2)
       (print-usage-and-exit cmd :prefix-message "Too many arguments.")))

    (bind ((depth-map (opticl:read-image-file (car args)))
           (:with opticl:with-image-bounds (dm-height dm-width) depth-map)
           (bg-image (if random-tile
                         (generate-random-tile dm-height tile-width grayscale)
                         (opticl:read-image-file (cadr args)))))
    (bind* ((depth-map (opticl:read-image-file (car args)))
            (:with opticl:with-image-bounds (dm-height dm-width) depth-map)
            (bg-image (if random-tile
                          (generate-random-tile dm-height tile-width grayscale)
                          (opticl:read-image-file (cadr args)))))
      (declare (type fixnum dm-height dm-width)
               (ignore dm-width))
      ;; FIXME: convert depth-map from an RGB image to grayscale if necessary

M src/package.lisp => src/package.lisp +1 -1
@@ 7,7 7,7 @@
(defpackage #:autostereogramify
  (:use #:cl)
  (:local-nicknames (#:utils #:nytpu.lisp-utils))
  (:import-from #:nytpu.lisp-utils.bind #:bind)
  (:import-from #:nytpu.lisp-utils.bind #:bind #:bind*)
  (:export #:generate-random-tile
           #:generate-stereogram
           #:main))