Lambda-gtk negative pointer

I tried to write my own pixel on (Gdk) pixbuf in Lisp. When I finally understood how I can work with C-pointers in CL, a new obstacle appeared - (gdk: pixbuf-get-pixels pb) returns me a negative number. My question is: can I somehow convert it to a valid pointer? My attempts to use cffi: convert-from-foreign and cffi: translate-from-foreign (what's the difference between them anyway?) Failed.

Below is my actual (not working) code:

(defun put-pixel (pixbuf x y r g b)
  (let ((p (+ (gdk:pixbuf-get-pixels pixbuf) (* x (gdk:pixbuf-get-n-channels pixbuf)) (* y (gdk:pixbuf-get-rowstride pixbuf)))))
    (setf (cffi:mem-aref p :unsigned-char 0) r)
    (setf (cffi:mem-aref p :unsigned-char 1) g)
    (setf (cffi:mem-aref p :unsigned-char 2) b)))
+3
source share
2 answers

I think lambda-gtk has an invalid binding for pixbuf-get-pixels.

- .

- mod:

CL-USER> (mod -1 (expt 2 #+cffi-features:x86 32 #+cffi-features:x86-64 64))
4294967295
+2

CFFI: TRANSLATE-FROM-FOREIGN . , CFFI: DEFINE-FOREIGN-TYPE, CFFI: TRANSLATE-FROM-FOREIGN, - Lisp.

CFFI: CONVERT-FROM-FOREIGN - , , - . CFFI: TRANSLATE-FROM-FOREIGN , , .

CFFI: CONVERT-TO-FOREIGN CFFI:. -TO-

+5

Source: https://habr.com/ru/post/1723161/


All Articles