[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pixmap -> bit array



This is a special case of Alex's previous query:

-------  (lots deleted)
Date: 24 Nov 1992 13:47:24 -0700 (MST)
From: Repenning Alexander <ralex@tigger.cs.colorado.edu> Subject: Fast
Access to PixMap Pixels

I need to access pixels of PixMaps and Bitmaps as fast as possible. Below
is a hack ...

(defun PIX-REF (Pixmap X Y)
...
(rref Pixmap :PixMap.rowBytes))
...(load-bits ...
(rref Pixmap :pixmap.baseaddr)
(logand #x7fff (rref Pixmap :PixMap.rowBytes)) (rref Pixmap
:PixMap.pixelSize)
...
-------

Here is a function that accesses the bits in a pixmap and stuffs a bit
array.  It works, but it certainly is not fast.  Are there faster ways to
do this?  Maybe moving more than one bit at a time?



(defun bitmap->bit_array (bitmap)
  (if (not (equal #@(0 0) (rref bitmap :bitmap.bounds.topleft))) (break
"bit_mask..."))
  (let* ((x (rref bitmap :bitmap.bounds.right))
         (y (rref bitmap :bitmap.bounds.bottom))
         (ara (make-array (list x y) :element-type 'bit :initial-element
0)))
    (dotimes_wt (i x)
                (dotimes (j y)
                  (if (pix-ref bitmap i j) (setf (sbit ara i j) 1 ))))
    ara))


(defun PIX-REF (bitmap X Y) 
  (ldb-test (byte 1 (- 7 (mod x 8)))  ;
            (%get-byte
             (rref bitmap :bitmap.baseaddr) 
             (+ (floor x 8)  (* (rref bitmap :bitmap.rowbytes) Y )))))

Thanks very much
Dave
David S. Bright                        bright@enh.nist.gov  
Microanalysis Research Group 
Chem. A113                                  
National Institute of Standards & Technology (NIST, formerly NBS)
Gaithersburg, MD 20899-0001                                          
USA
301-975-3911