Bitmap/Read a PPM file: Difference between revisions
Content added Content deleted
Line 274: | Line 274: | ||
(defun read-ppm-file-header (file) |
(defun read-ppm-file-header (file) |
||
(with-open-file (s file :direction :input) |
(with-open-file (s file :direction :input) |
||
(do ((count 0 (1+ count)) |
(do ((failure-count 0 (1+ failure-count)) |
||
⚫ | |||
(failure-count 0 (1+ failure-count)) |
|||
(if (> (length t1) 0) |
|||
⚫ | |||
(cons t1 tokens) |
|||
tokens)))) |
|||
((>= (length tokens) 4) (values (nreverse tokens) |
|||
(file-position s))) |
(file-position s))) |
||
(when (>= failure-count 10) |
(when (>= failure-count 10) |
||
(error (format nil "File ~a does not seem to be a proper ppm file - maybe too many comment lines" file))) |
(error (format nil "File ~a does not seem to be a proper ppm file - maybe too many comment lines" file))) |
||
(when (= |
(when (= (length tokens) 1) |
||
(when (not (or (string= (first tokens) "P6") (string= (first tokens) "P3"))) |
(when (not (or (string= (first tokens) "P6") (string= (first tokens) "P3"))) |
||
(error (format nil "File ~a is not a ppm file - wrong magic-number. Read ~a instead of P6 or P3 " file (first tokens)))))))) |
(error (format nil "File ~a is not a ppm file - wrong magic-number. Read ~a instead of P6 or P3 " file (first tokens)))))))) |