Created
September 18, 2017 20:51
-
-
Save phoe/3807df6283fd04499adf70747a643cac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; (ql:quickload :qtools) | |
(defmacro with-qimage-from-vector ((image-var vector width height) &body body) | |
"Establishes a lexical environment, in which IMAGE-VAR is bound to a QImage | |
created from the ARGB contents of VECTOR, with width WIDTH and height HEIGHT." | |
(with-gensyms (length v) | |
`(let* ((,length (array-dimension ,vector 0)) | |
(,v (make-static-vector ,length :initial-contents vector))) | |
(unwind-protect | |
(with-finalizing | |
((,image-var (q+:make-qimage | |
(static-vector-pointer ,v) | |
,width ,height | |
(q+:qimage.format_argb32)))) | |
,@body) | |
(free-static-vector ,v))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment