b8cc0a56b57e

Order array dimensions as width, height
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Tue, 16 Jan 2018 19:56:02 -0500
parents 7e4d5c6a9b2a
children 66846306020f
branches/tags (none)
files src/main.lisp

Changes

--- a/src/main.lisp	Tue Jan 16 19:47:02 2018 -0500
+++ b/src/main.lisp	Tue Jan 16 19:56:02 2018 -0500
@@ -67,14 +67,14 @@
   (let* ((width (read-number stream))
          (height (read-number stream))
          (bit-depth (if (eql :pbm format) 1 (read-number stream)))
-         (data (make-array (list height width)
+         (data (make-array (list width height)
                  :element-type (pixel-type format bit-depth)))
          (reader (if binary? #'read-byte #'read-number)))
     (when binary?
       (read-char stream)) ; chomp last newline before bytes
-    (dotimes (row height)
-      (dotimes (col width)
-        (setf (aref data row col)
+    (dotimes (y height)
+      (dotimes (x width)
+        (setf (aref data x y)
               (ecase format
                 (:pbm (funcall reader stream))
                 (:pgm (funcall reader stream))
@@ -89,12 +89,12 @@
 (defun write% (data stream format binary? maximum-value)
   (let ((stream (flexi-streams:make-flexi-stream stream :external-format :ascii))
         (writer (if binary? #'write-byte #'write-number)))
-    (destructuring-bind (height width) (array-dimensions data)
+    (destructuring-bind (width height) (array-dimensions data)
       (format stream "P~D~%~D ~D~%~D~%"
               (magic-byte format binary?) width height maximum-value)
-      (dotimes (row height)
-        (dotimes (col width)
-          (let ((pixel (aref data row col)))
+      (dotimes (y height)
+        (dotimes (x width)
+          (let ((pixel (aref data x y)))
             (ecase format
               (:pbm (funcall writer pixel stream))
               (:pgm (funcall writer pixel stream))