Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
9.5
10.0
10.1
10.2
10.3
10.4
10.5
11.0
11.1
11.2
Statistic
FMM
Blog
Creates an image source that reads from a location specified by a Path.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
CGImageSource | 3.4 | ✅ Yes | ❌ No | ❌ No | ✅ Yes, on macOS | ✅ Yes |
Parameter | Description | Example |
---|---|---|
Path | The platform specific native file path. | "/test.jpg" |
Returns the reference number for this image source or error message.
Load image and show it:
Set Variable [ $path ; Value: "/Users/cs/Pictures/IMG_3625.jpg" ]
Set Variable [ $img ; Value: MBS( "CGImageSource.CreateWithPath"; $path ) ]
Set Field [ test::output ; MBS( "CGImageSource.ImageAtIndex"; $img; 0) ]
Set Variable [ $r ; Value: MBS( "CGImageSource.Release"; $img ) ]
Read HEIC image:
Set Variable [ $path ; Value: "/Users/cs/Desktop/IMG_3552.HEIC" ]
Set Variable [ $ImageSource ; Value: MBS( "CGImageSource.CreateWithPath"; $path) ]
If [ MBS("IsError") = 0 ]
# you can get metadata as JSON to check later...
Set Variable [ $$MetaData ; Value: MBS( "CGImageSource.Properties"; $ImageSource ) ]
Set Variable [ $$ImageMetaData ; Value: MBS( "CGImageSource.Properties"; $ImageSource; 0 ) ]
# get image to show
Set Variable [ $image ; Value: MBS( "CGImageSource.ImageAtIndex"; $ImageSource; 0; "PNG"; "image.png") ]
If [ MBS("IsError") = 0 ]
Set Field [ Untitled::image ; $image ]
End If
Set Variable [ $r ; Value: MBS( "CGImageSource.Release"; $ImageSource ) ]
End If
Created 18th August 2014, last changed 27th January 2020
CGImageSource.CreateWithData - CGImageSource.CreateWithURL
Feedback: Report problem or ask question.