[Openmcl-devel] Any ideas why this isn't working?

Ron Garret ron at flownet.com
Mon Feb 10 06:46:35 PST 2020


Trying to use a CGImageDestination to create an animated GIF following the recipe at:

https://stackoverflow.com/questions/15584931/creating-an-animated-gif-in-cocoa-defining-frame-type

but creating the CGImageDestination seems to fail:

Welcome to Clozure Common Lisp Version 1.11-r16812M  (DarwinX8664)!

? (setf url (#_CFURLCreateWithString +null-ptr+ (nsstr "file:///Users/ron/Desktop/foo.gif") +null-ptr+))
#<NS-URL file:///Users/ron/Desktop/foo.gif (#x6000008650C0)>
? (#_CGImageDestinationCreateWithURL url #$kUTTypeGIF 2 +null-ptr+)
#<NS-OBJECT [uninitialized] (#x6000000B49A0)>
? 

Trying to use the uninitialized object doesn’t crash CCL, but also doesn’t produce any results.  Any idea what I’m doing wrong here?

Thanks,
rg

P.S.: Some additional code just in case you want to noodle around with this:

(defun make-blank-image (x y)
  (#/initWithSize: (make-instance 'ns:ns-image) (nssize x y)))

(defun nsstr (s)
  (with-encoded-cstrs :utf-8 ((s s))
    (#/stringWithUTF8String: ns:ns-string s)))

(setf prep (#/dictionaryWithObject:forKey:
            ns:ns-dictionary
            (#/dictionaryWithObject:forKey:
             ns:ns-dictionary
             (#/initWithFloat: (#/alloc ns:ns-number) (coerce 0.2 'single-float))
             #$kCGImagePropertyGIFDelayTime)
            #$kCGImagePropertyGIFDictionary))

(setf img (make-blank-image 10 10))
(setf dest (#_CGImageDestinationCreateWithURL url #$kUTTypeGIF 2 +null-ptr+)) ; Not working
(#_CGImageDestinationAddImage dest img prep)
(#_CGImageDestinationFinalize dest)




More information about the Openmcl-devel mailing list