Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
creating CG types in beta?
-
In trying to grab screenshots from a video, I believe I need to define
CGImage
, andCGImageRef
.
Howevever,ObjCClass('CGImage')
doesnt find that class.Looking at the headers, CGImage is just a struct, so I think i can create that type as a structure, however I still need to pass a function pointer to CGImageDestroy, which also doesnt seem to be recognized by the cdll.
I am sure I am missing something incredibly basic....
-
Just treat
CGImageRef
as a pointer (c_void_p
), and don't worry about the internal structure. It's an "opaque" type, and you'd never access its structure directly in C code either. The CoreGraphics framework (whereCGImageRef
is defined) is just plain C, not Objective-C, so you usually manipulate its "objects" using functions, e.g.CGImageGetWidth()
etc.It's usually easier to deal with
CGImageRef
if you wrap it in aUIImage
, using+imageWithCGImage:
(or some variation, like+imageWithCGImage:scale:orientation:
). -
Thanks, i ended up figuring that part out, but wasnt sure because i kept getting crashes. turns out NSError was throwing me off, because i had to pass a pointer to an NSError object, rather than the object itself... or, better yet, None.