Patrick Stein a écrit :
> On Tue, Feb 17, 2009 at 10:52 AM, fred voisin <fred@...> wrote:
>> may be it's trivial, I'm quite surprised to not succeed in reading
>> binary files, as for instance pbm file (but also some other formats for
>> audio etc).
>
> This code works perfectly fine for me with Darwin PPC and Linux x86.
> Looking at your output, I think the problem is in your memory of PBM
> binary files. With PBM ASCII files, there are only zeros and ones.
> With PBM binary files, the bits are packed eight to a byte.... hence
> the (CEILING WIDTH 8).
>
Thank's for all your answers (Volkan, Nikodemus, Patrick),
finally I got it, the only point was just, as you said, that in P4
binary PBM files the bits are packed eight to a byte so I had success
(read generated from your c code) using the following (rough and very
basic) lisp function to convert bytes red with read-byte:
(defun int8bits (n r)
(if (> n 1)
(int8bits (floor (/ n 2)) (cons (mod n 2) r))
(let ((r (cons n r)))
(append (make-list (- 8 (length r)) :initial-element 0) r))))
(int8bits 128 nil)
> (1 0 0 0 0 0 0 0)
I suspect there is a faster and nicer lisp way to do it, please which
one do you suggest ?
Thank's in advance,
Regards,
Fred
|