Returning imageData from NSImage?

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
Zax
Posts: 473
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Returning imageData from NSImage?

Post by Zax » Thu Aug 31, 2023 10:46 am

Hello,

I'm new to Externals and I don't understand anything about objective-c stuff but I'm trying to get the icon of a MacOS Finder file to populate the imageData of a LC image control.

I built a script by copying bits found on the net but my problem concerns the final step: returning data that can be used by LC. I would like something like:

Code: Select all

set the imageData of image "MyImage" to MyExternal("/path to a file")
This is the end of my external script:

Code: Select all

put ObjC_NSBitmapImageRepRepresentationUsingType(tBitmapImageRep, 4, nothing) into tImageData // 4 for PNG
put DataFromNSData(tImageData) into dataResult // ???
return what ???

Code: Select all

private foreign handler ObjC_NSBitmapImageRepRepresentationUsingType(in pBitmapImageRep as ObjcId, in pType as CInt, in pProps as optional ObjcId) \
    returns ObjcId binds to "objc:NSBitmapImageRep.-representationUsingType:properties:"
Thank you for your help.

Zax
Posts: 473
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Returning imageData from NSImage?

Post by Zax » Wed Oct 11, 2023 8:33 am

Thanks, I'll try as soon as I can :)

Post Reply

Return to “LiveCode Builder”