[Openmcl-devel] Advice needed: best way to fram a Lisp array into an ns-image

Ron Garret ron at awun.net
Sat Jan 19 06:19:10 UTC 2008


On Jan 18, 2008, at 7:10 PM, Ron Garret wrote:

> That's pretty much what I'm doing, so I guess that means I'm kinda on
> the right track.

Well, I thought I was on the right track.  I tried this:

(defun stuff-pixels (pixels)
   (bind ((x y bpp) (array-dimensions pixels)
          (:values v ptr) (make-heap-ivector (* x y bpp) '(unsigned- 
byte 8)))
     (dotimes (i (* x y bpp))
       (setf (aref v i) (row-major-aref pixels i)))
     (#/ 
initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel 
:
      (#/alloc ns:ns-bitmap-image-rep)
      ptr
      x y 8 3 0 0 #@"NSCalibratedRGBColorSpace" (* x 3) 24)))

It seems to work:

? (stuff-pixels #3A(((0 0 0) (0 0 0) (0 0 0) (0 0 0))
((0 0 0) (0 0 0) (0 0 0) (0 0 0))
((0 0 0) (0 0 0) (0 0 0) (0 0 0))((0 0 0) (0 0 0) (0 0 0) (0 0 0)))
)
#<NS-BITMAP-IMAGE-REP NSBitmapImageRep 0xa992900 Size={4, 4}  
ColorSpace=NSCalibratedRGBColorSpace BPS=8 BPP=24 Pixels=4x4 Alpha=NO  
Planar=NO Format=0 (#xA992900)>
?

But the resulting bitmapRep is corrupt:

? (#/bitmapData *)
Unhandled exception 11 at 0x7fff82855d80, context->regs at #xb0c3e350
Exception occurred while executing foreign code
? for help
[58183] OpenMCL kernel debugger:

rg




More information about the Openmcl-devel mailing list