Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSImageMBS class.

NSImageMBS.cancelIncrementalLoad

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Cancels the current download operation immediately, if the image is being incrementally loaded.

This call has no effect if the image is not loading.

NSImageMBS.Constructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The default constructor creating a dummy NSImage object.

See also:

NSImageMBS.Constructor(data as Memoryblock)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The data constructor calling initWithData internally.

Calls initWithData.
On success the image is valid and the handle is not zero.

See also:

NSImageMBS.Constructor(file as folderitem)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The file constructor calling initWithContentsOfURL(file) internally.

Calls initWithContentsOfURL.
On success the image is valid and the handle is not zero.

See also:

NSImageMBS.Constructor(image as Picture, mask as picture = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a new NSImageMBS object based on the image data in a Xojo picture.
Example
Var img as new NSImageMBS(pict)

Optional you can pass a picture with the mask. It is valid to use the mask property of the image for the second parameter.

With 11.3 plugins we are deprecating to pass a mask. The plugin prefers to simply take the mask or alpha channel of the picture itself.

On success the image is valid and the handle is not zero.
Calls initWithPicture.

See also:

NSImageMBS.Constructor(width as Double, height as Double)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 7.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The size constructor calling initWithSize internally.

Calls initWithSize.
On success the image is valid and the handle is not zero.

See also:

NSImageMBS.CopyMask as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 7.5 ✅ Yes ❌ No ❌ No ❌ No All
Copies the content of the NSImage in current size.
Example
Var f as FolderItem
Var n as NSImageMBS

f=SpecialFolder.Desktop.Child("test.png")
n=new NSImageMBS(f)
Backdrop=n.CopyMask

Copies only the alpha channel as mask.
Returns nil on any error.

Not implemented for iOS.

NSImageMBS.CopyPicture(CGColorSpace as Variant = nil, BackgroundColor as NSColorMBS = nil) as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 7.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Copies the content of the NSImage in current size.
Example
Var f as FolderItem
Var n as NSImageMBS

f=SpecialFolder.Desktop.Child("test.png")
n=new NSImageMBS(f)
Backdrop=n.CopyPicture // background is black

A convenience function instead of using CGPictureContextMBS with DrawIntoCGContextAtRect.

Returns nil on any error.

With Colorspace parameter you can pass a RGB CGColorspace to define which colorspace is used. Default is DeviceRGB, but you could also pass generic RGB or other.

If BackgroundColor is not nil, the image is filled in background with this color and NSImage rendered on top of it.

Implemented for iOS in v22.4 to return underlaying UIImage as Xojo picture. Colorspace and background are ignored as picture is passed directly.

NSImageMBS.CopyPictureRect(x as Integer, y as Integer, w as Integer, h as Integer, CGColorSpace as Variant = nil, BackgroundColor as NSColorMBS = nil) as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 13.2 ✅ Yes ❌ No ❌ No ❌ No All
Copies the content of the NSImage from the given rectangle.
Example
Var f as FolderItem
Var n as NSImageMBS

f=SpecialFolder.Desktop.Child("test.png")
n=new NSImageMBS(f)
Backdrop=n.CopyPicture // background is black

A convenience function instead of using CGPictureContextMBS with DrawIntoCGContextAtRect.

Returns nil on any error.

With Colorspace parameter you can pass a RGB CGColorspace to define which colorspace is used. Default is DeviceRGB, but you could also pass generic RGB or other.

If BackgroundColor is not nil, the image is filled in background with this color and NSImage rendered on top of it.

Not implemented for iOS.

NSImageMBS.CopyPictureWithAlpha as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 15.1 ✅ Yes ❌ No ❌ No ❌ No All
Copies the content of the NSImage in current size.

This is a function for Cocoa target which returns picture with alpha channel.
Returns nil on any error.

Not implemented for iOS.

NSImageMBS.CopyPictureWithAlphaRect(x as Integer, y as Integer, w as Integer, h as Integer) as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 15.1 ✅ Yes ❌ No ❌ No ❌ No All
Copies the content of the NSImage in given rectangle.

This is a function for Cocoa target which returns picture with alpha channel.
Returns nil on any error.

Not implemented for iOS.

NSImageMBS.CopyPictureWithMask(CGColorSpace as Variant = nil) as picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Drawing MBS MacBase Plugin 7.5 ✅ Yes ❌ No ❌ No ❌ No All
Copies the content of the NSImage in current size.
Example
Var f as FolderItem
Var n as NSImageMBS

f=SpecialFolder.Desktop.Child("test.png")
n=new NSImageMBS(f)
Backdrop=n.CopyPictureWithMask

Copies the picture and its mask.
This function is faster than CopyPicture and CopyMask combined as the picture is only copied one time to an internal buffer.

A convenience function instead of using CGPictureContextMBS with DrawIntoCGContextAtRect.

Returns nil on any error.

With Colorspace parameter you can pass a RGB CGColorspace to define which colorspace is used. Default is DeviceRGB, but you could also pass generic RGB or other.

Not implemented for iOS.

The items on this page are in the following plugins: MBS MacBase Plugin.


The biggest plugin in space...