Jump to content

Bitmap/Read a PPM file: Difference between revisions

Line 263:
 
(defparameter *whitespaces-chars* '(#\SPACE #\RETURN #\TAB #\NEWLINE #\LINEFEED))
 
 
(defun read-header-chars (stream &optional (delimiter-list *whitespaces-chars*))
Line 272 ⟶ 271:
(when (char= c #\#) ;;skip comments
(read-line stream))))
 
 
(defun read-ppm-file-header (file)
Line 279 ⟶ 277:
(failure-count 0 (1+ failure-count))
(tokens nil (cons (read-header-chars s) tokens)))
((>= count 4) (values (nreverse tokens) ;; try to collect 4 tokens in a ppm header (magic-number width height max-value)
(file-position s)))
(when (>= failure-count 10)
(error (format nil "File ~a does not seem to be a proper ppm file - maybe too many comment lines" file))))))
(when (= count 1)
(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))))))))
 
(defun read-ppm-image (file)
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.