Platforms to show: All Mac Windows Linux Cross-Platform
Back to NSImageMBS class.
NSImageMBS.addRepresentation(img as NSImageRepMBS)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 8.4 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
After invoking this method, you may need to explicitly set features of the new image representation, such as the size, number of colors, and so on. This is true particularly when the NSImage object has multiple image representations to choose from. See NSImageRep and its subclasses for the methods you use to complete initialization.
Any representation added by this method is retained by the receiver. Image representations cannot be shared among multiple NSImage objects.
Some examples using this method:
NSImageMBS.BMPRepresentation as Memoryblock
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 7.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
BMP does not support masks.
NSImageMBS.BMPRepresentationMT as Memoryblock
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 13.1 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
BMP does not support masks.
The work is performed on a preemptive thread, so this function does not block the application and can yield time to other Xojo threads. Must be called in a Xojo thread to enjoy benefits. If called in main thread will block, but keep other background threads running.
If you run several threads calling MT methods, you can get all CPU cores busy while main thread shows GUI with progress window.
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 |
This call has no effect if the image is not loading.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 7.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
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 |
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 |
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 |
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 |
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 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 |
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 |
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 |
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 |
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 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.
NSImageMBS.DrawIntoCGContextAtPoint(cgcontext as Integer, x as Double, y as Double, sx as Double, sy as Double, SourceW as Double, SourceH as Double, operation as Integer, fraction as Double) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 7.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Same as DrawIntoCGContextAtRect, but with a point instead of a rectangle.
NSImageMBS.DrawIntoCGContextAtRect(cgcontext as Integer, x as Double, y as Double, w as Double, h as Double, SourceX as Double, SourceY as Double, SourceW as Double, SourceH as Double, operation as Integer, fraction as Double) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 7.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Draws the image into a CGContext. You need to specify first the destination rectangle followed by the source rectangle.
fraction:
The opacity of the image, specified as a value from 0.0 to 1.0. Specifying a value of 0.0 draws the image as fully transparent while a value of 1.0 draws the image as fully opaque. Values greater than 1.0 are interpreted as 1.0.
operation codes:
NSCompositeClear | = 0 | Transparent. |
NSCompositeCopy | = 1 | Source image. |
NSCompositeSourceOver | = 2 | Source image wherever source image is opaque, and destination image elsewhere. |
NSCompositeSourceIn | = 3 | Source image wherever both images are opaque, and transparent elsewhere. |
NSCompositeSourceOut | = 4 | Source image wherever source image is opaque but destination image is transparent, and transparent elsewhere. |
NSCompositeSourceAtop | = 5 | Source image wherever both images are opaque, destination image wherever destination image is opaque but source image is transparent, and transparent elsewhere. |
NSCompositeDestinationOver | = 6 | Destination image wherever destination image is opaque, and source image elsewhere. |
NSCompositeDestinationIn | = 7 | Destination image wherever both images are opaque, and transparent elsewhere. |
NSCompositeDestinationOut | = 8 | Destination image wherever destination image is opaque but source image is transparent, and transparent elsewhere. |
NSCompositeDestinationAtop | = 9 | Destination image wherever both images are opaque, source image wherever source image is opaque but destination image is transparent, and transparent elsewhere. |
NSCompositeXOR | = 10 | Exclusive OR of source and destination images. |
NSCompositePlusDarker | = 11 | Sum of source and destination images, with color values approaching 0 as a limit. |
NSCompositeHighlight | = 12 | Source image wherever source image is opaque, and destination image elsewhere. |
NSCompositePlusLighter | = 13 | Sum of source and destination images, with color values approaching 1 as a limit. |
Returns true on success and false on failure.
Some examples using this method:
NSImageMBS.GIFRepresentation as Memoryblock
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 7.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
GIF does support masks in a limited way.
NSImageMBS.GIFRepresentationMT as Memoryblock
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 13.1 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
GIF does support masks in a limited way.
The work is performed on a preemptive thread, so this function does not block the application and can yield time to other Xojo threads. Must be called in a Xojo thread to enjoy benefits. If called in main thread will block, but keep other background threads running.
If you run several threads calling MT methods, you can get all CPU cores busy while main thread shows GUI with progress window.
NSImageMBS.imageByFadingToFraction(fraction as Double) as NSImageMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 7.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns nil on failure.
NSImageMBS.imageByScalingToSize(width as Double, height as Double) as NSImageMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 7.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns nil on failure.
Internally creates a copy of the image.
See also:
- imageByScalingToSize(width as Double, height as Double, fraction as Double) as NSImageMBS
- imageByScalingToSize(width as Double, height as Double, fraction as Double, flip as boolean, proportionally as boolean) as NSImageMBS
Some examples using this method:
NSImageMBS.imageByScalingToSize(width as Double, height as Double, fraction as Double) as NSImageMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 7.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns nil on failure.
Internally creates a copy of the image.
See also:
NSImageMBS.imageByScalingToSize(width as Double, height as Double, fraction as Double, flip as boolean, proportionally as boolean) as NSImageMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 7.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns nil on failure.
The image can be flipped vertically with the flip property.
Internally creates a copy of the image.
See also:
NSImageMBS.imageWithSymbolConfiguration(configuration as NSImageSymbolConfigurationMBS) as NSImageMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 22.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
NSImageMBS.imageWithTintColor(tintColor as NSColorMBS) as NSImageMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 20.1 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Input image should be grayscale.
NSImageMBS.initWithContentsOfURL(file as folderitem) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 7.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns true on success and false on failure.
See also:
NSImageMBS.initWithContentsOfURL(url as string) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 7.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns true on success and false on failure.
See also:
NSImageMBS.initWithData(data as Memoryblock) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 7.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Returns true on success and false on failure.
NSImageMBS.initWithDataIgnoringOrientation(data as Memoryblock) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
An initialized NSImage instance, or nil if the method cannot create an image representation from the contents of the specified data object.
Available in Mac OS X v10.6 and later.
NSImageMBS.initWithIconRef(IconHandle as Integer) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
IconHandle: A reference to a Carbon icon resource (IconRef).
Creates one or more bitmap image representations, one for each size icon contained in the IconRef data structure. This initialization method automatically retains the data in the iconRef parameter and loads the bitmaps from that data file lazily.
Available in Mac OS X v10.5 and later.
NSImageMBS.initWithPasteboard as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 9.6 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
The specified pasteboard should contain a type supported by one of the registered NSImageRep subclasses. Table 1 lists the default pasteboard types and file extensions for several NSImageRep subclasses.
NSImageMBS.initWithPicture(img as picture, mask as picture = nil) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Cocoa Drawing | MBS MacBase Plugin | 7.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
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.
Some examples using this method:
The items on this page are in the following plugins: MBS MacBase Plugin.