我最近开始学习Lisp,并想编写一个使用gtk界面的程序。我已经在CMUCL上安装了lambda-gtk绑定。我想要在pixbuf上具有putpixel/getpixel功能。但是我发现我无法直接访问内存(或者只是不知道如何)。
函数(gdk:pixbuf-get-pixels pixbuf)返回给我一个数字——内存地址,我猜测。在C++中,我可以轻松地获得我需要的像素。有没有办法在Lisp中编写自己的putpixel函数?
我最近开始学习Lisp,并想编写一个使用gtk界面的程序。我已经在CMUCL上安装了lambda-gtk绑定。我想要在pixbuf上具有putpixel/getpixel功能。但是我发现我无法直接访问内存(或者只是不知道如何)。
函数(gdk:pixbuf-get-pixels pixbuf)返回给我一个数字——内存地址,我猜测。在C++中,我可以轻松地获得我需要的像素。有没有办法在Lisp中编写自己的putpixel函数?
>(defparameter *p* (cffi:foreign-alloc :unsigned-char :count 10))
;; allocate 10 bytes
*P*
> (setf (cffi:mem-aref *p* :unsigned-char 0) 10)
;; access *p* as an array of bytes and set its 0th element to 10
10
> (cffi:mem-aref *p* :unsigned-char 0)
;; access *p* as an array of bytes and take its 0th element
10
> (cffi:make-pointer 123)
;; make a pointer that points to given address
#.(SB-SYS:INT-SAP #X0000007B)