Skip to content

Instantly share code, notes, and snippets.

@joelreymont
Created December 31, 2009 16:34
Show Gist options
  • Save joelreymont/266789 to your computer and use it in GitHub Desktop.
Save joelreymont/266789 to your computer and use it in GitHub Desktop.
(defun cocoa-get-image-bytes (image)
(let ((bitmap (objc:invoke
(objc:invoke "NSBitmapImageRep" "alloc")
"initWithData:"
(objc:invoke image "TIFFRepresentation"))))
(if bitmap
(let ((data (objc:invoke-into
'(:pointer (:unsigned :char))
bitmap "bitmapData")))
(values bitmap data))
nil)))
;;; Free image data
(defun cocoa-free-image-bytes (bitmap)
(objc:invoke bitmap "release"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment