# HG changeset patch # User Steve Losh # Date 1516150562 18000 # Node ID b8cc0a56b57e1adca8b13499de02b3ca811071ba # Parent 7e4d5c6a9b2af7d8c559ee0abf01ae8718ce03bc Order array dimensions as width, height diff -r 7e4d5c6a9b2a -r b8cc0a56b57e src/main.lisp --- 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))