Platforms to show: All Mac Windows Linux Cross-Platform

Back to CIImageMBS class.

CIImageMBS.AsNSImageMBS as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 13.0 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates a NSImageMBS which references the given CIImage.
Example
// make a dummy CIImage
dim Logo as Picture = LogoMBS(500)
dim jpeg as string = PictureToJPEGStringMBS(logo, 80)
dim ci as CIImageMBS = CIImageMBS.imageWithData(jpeg)

// convert to NSImage
dim ni as NSImageMBS = ci.AsNSImageMBS

// and display
Backdrop = ni.CopyPictureWithMask

Returns nil on error.
Result declared as Variant to avoid plugin dependencies.

CIImageMBS.autoAdjustmentFilters as CIFilterMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 13.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns all filters that perform auto adjustment.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.jpg")
dim image as CIImageMBS = CIImageMBS.imageWithContentsOfFile(f)

dim filters() as CIFilterMBS = image.autoAdjustmentFilters

dim beginImage as CIImageMBS = image
for each filter as CIFilterMBS in filters
filter.ValueAsCIImage("inputImage") = beginImage
beginImage = filter.ValueAsCIImage("outputImage")
next

Backdrop = beginImage.RenderPicture

An array of auto adjustment filters to apply to the image. The filters are preset with values for correcting deficiencies in the supplied image.

CIImageMBS.autoAdjustmentFiltersWithOptions(options as dictionary) as CIFilterMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 13.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a subset of the filters that perform auto adjustment.
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.jpg")
dim image as CIImageMBS = CIImageMBS.imageWithContentsOfFile(f)

dim options as new Dictionary
options.Value(CIImageMBS.kCIImageAutoAdjustEnhance) = true
options.Value(CIImageMBS.kCIImageAutoAdjustRedEye) = true

dim filters() as CIFilterMBS = image.autoAdjustmentFiltersWithOptions(options)

dim beginImage as CIImageMBS = image
for each filter as CIFilterMBS in filters
filter.ValueAsCIImage("inputImage") = beginImage
beginImage = filter.ValueAsCIImage("outputImage")
next

Backdrop = beginImage.RenderPicture

options: You can control which filters are returned by supplying one or more of the keys described in "Auto Adjustment Keys."
The options dictionary can also contain a CIDetectorImageOrientation key. This key is a number with the same value as defined by the TIFF and EXIF specifications; values can range from 1 through 8. The value specifies where the origin (0,0) of the image is located. If not present, the default value is 1, which means the origin of the image is top, left. For details on the image origin specified by each value, see kCGImagePropertyOrientation.

Returns an array of auto adjustment filters, filtered by the supplied options, to apply to the image. The filters are preset with values for correcting deficiencies in the supplied image.

CIImageMBS.Constructor(CGLayer as CGLayerMBS, options as Dictionary = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 14.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates and returns an image object from the contents supplied by a CGLayer object, using the specified options.

layer: A CGLayer object. For more information see Quartz 2D Programming Guide and CGLayer Reference.
options: A dictionary specifying image options.

Returns an image object initialized with the contents of the layer object and set up with the specified options.

See also:

CIImageMBS.Constructor(data as Memoryblock, Length as Integer, BytesPerRow as Integer, width as Integer, height as Integer, format as Integer, cgcolorspace as CGColorSpaceMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 7.3 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a CIImage from a RAW memory buffer.

Data points directly to the row data.
Length is the size of the memoryblock in bytes.
BytesPerRow is the size of a row in bytes.
Width and height are the dimensions of the image.
Format must be one of this constants: kCIFormatRGBAf, kCIFormatRGBA16 and kCIFormatARGB8.
Colorspace is the CoreGraphics Colorspace object to be used.

On success, the handle is not zero.

See also:

CIImageMBS.copy as CIImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 17.4 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a copy of the image.

CIImageMBS.CreateCGImage(r as CGRectMBS = nil) as CGImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 13.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a new image with the content of the CIImage.
Example
dim logo as Picture = LogoMBS(500)
dim ci as CIImageMBS = CIImageMBS.imageWithPicture(logo)
dim cg as CGImageMBS = ci.CreateCGImage
Backdrop = cg.Picture

Render the region 'r' of image 'im' into a temporary buffer using the context, then create and return a new CoreGraphics image with the results.
If r is nil, the whole image extent is used.

See also:

CIImageMBS.CreateCGImage(r as CGRectMBS, ColorSpace as CGColorSpaceMBS) as CGImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 13.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates a new image with the content of the CIImage.

Render the region 'r' of image 'im' into a temporary buffer using the context, then create and return a new CoreGraphics image with the results.
If r is nil, the whole image extent is used.

See also:

CIImageMBS.imageByApplyingOrientation(orientation as Integer) as CIImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 15.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a new image representing the original image with a transform appied to it based on an orientation value.
Example

// use CIImage to rotate to always be top left orientation
Dim ciImage As CIImageMBS = New CIImageMBS(file)

Dim orientation As Integer = ciImage.properties.Lookup("Orientation", 0)
if orientation <> 0 then
ciImage = ciImage.imageByApplyingOrientation(orientation)
end if

Dim cgPic As CGImageMBS = ciImage.CreateCGImage
Dim pic As Picture = cgPic.Picture
ImageViewer1.Image = pic

Orientation values from 1 to 8 as defined in the TIFF spec are supported.
Returns original image if the image is of infinite extent.

Possible orientation values:
Valueorientationdetails
1top leftrow 0 top, col 0 lhs
2top rightrow 0 top, col 0 rhs
3bottom rightrow 0 bottom, col 0 rhs
4bottom leftrow 0 bottom, col 0 lhs
5left toprow 0 lhs, col 0 top
6right toprow 0 rhs, col 0 top
7right bottomrow 0 rhs, col 0 bottom
8left bottomrow 0 lhs, col 0 bottom

Some examples using this method:

CIImageMBS.ImageByApplyingTransform(transform as NSAffineTransformMBS) as CIImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 7.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns a new image representing the original image with the transform 'matrix' appended to it.

CIImageMBS.imageByClampingToExtent as CIImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 15.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Return a new infinte image by replicating the pixels of the receiver image's extent.

CIImageMBS.imageByCompositingOverImage(dest as CIImageMBS) as CIImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 16.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a new image created by compositing the original image over the specified destination image.

dest: An image to serve as the destination of the compositing operation.

Returns an image object representing the result of the compositing operation.

Calling this method is equivalent to using the CISourceOverCompositing filter. To use other compositing operations and blending modes, create a CIFilter object using one of the built-in filters from the CICategoryCompositeOperation category. For details, see Core Image Filter Reference.

Available in OS X v10.4 and later.

CIImageMBS.imageByCroppingToRect(r as CGRectMBS) as CIImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 13.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns a new image that represents the original image after cropping to a rectangle.

Available in OS X v10.5 and later.

CIImageMBS.properties as Dictionary

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 13.0 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the metadata properties of an image.

If the image is the output of one or more CIFilters, then the metadata of the root inputImage will be returned.

CIImageMBS.releaseHandle

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Decrements the retain count of a CIImage reference.

Each retain must have a release. Too many releases and your app will crash, too many retains and it will leak memory.
Use only if you really know what you are doing.

CIImageMBS.RenderNSImage(UseSoftwareRenderer as boolean = false) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 7.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates a picture based of the CIImage content.
Example
dim f as CIFilterEdgesMBS

f=new CIFilterEdgesMBS
f.inputImage=NewCIImagewithFileMBS(SpecialFolder.Desktop.Child("Paris.jpg"))
f.inputIntensity=5

dim n as NSImageMBS
n=f.outputImage.RenderNSImage(false)

Creates a new NSImage, creates a CGContext for it, draws the image into the buffer and returns it as a Xojo object.

Returns nil on failure.
Rendering the image will cause the calculations to be done so this call is quite expensive.

If UseSoftwareRenderer is true, the hardware acceleration is not used.

Some examples using this method:

CIImageMBS.RenderPicture(Width as Integer = 0, Height as Integer = 0, UseSoftwareRenderer as boolean = false) as Picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 7.3 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Creates a picture based of the CIImage content.
Example
dim f as CIFilterEdgesMBS

f=new CIFilterEdgesMBS
f.inputImage=NewCIImagewithFileMBS(SpecialFolder.Desktop.Child("Paris.jpg"))
f.inputIntensity=5
Backdrop=f.outputImage.RenderPicture

Creates a new image buffer, creates a CGContext for it, draws the image into the buffer and returns it as a picture with mask. If you need picture with alpha channel, please use RenderPictureWithAlpha function.

Returns nil on failure.
Rendering the image will cause the calculations to be done so this call is quite expensive.

If UseSoftwareRenderer is true, the hardware acceleration is not used.

Some examples using this method:

CIImageMBS.RenderPictureWithAlpha(Width as Integer = 0, Height as Integer = 0, UseSoftwareRenderer as boolean = false) as Picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 15.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Creates a picture based of the CIImage content.
Example
dim f as CIFilterEdgesMBS

f=new CIFilterEdgesMBS
f.inputImage=NewCIImagewithFileMBS(SpecialFolder.Desktop.Child("Paris.jpg"))
f.inputIntensity=5
Backdrop= f.outputImage.RenderPictureWithAlphaMT

Creates a new image buffer, creates a CGContext for it, draws the image into the buffer and returns it as a Xojo picture with alpha channel.

Returns nil on failure.
Rendering the image will cause the calculations to be done so this call is quite expensive.

If UseSoftwareRenderer is true, the hardware acceleration is not used.

CIImageMBS.RenderPictureWithAlphaMT(Width as Integer = 0, Height as Integer = 0, UseSoftwareRenderer as boolean = false) as Picture

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 15.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Creates a picture based of the CIImage content.

Same as the other RenderPictureWithAlpha function, but threaded.

Creates a new image buffer, creates a CGContext for it, draws the image into the buffer and returns it as a Xojo picture with alpha channel.

Returns nil on failure.
Rendering the image will cause the calculations to be done so this call is quite expensive.

If UseSoftwareRenderer is true, the hardware acceleration is not used.

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.

CIImageMBS.retainHandle

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 14.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Increments the retain count of a CIImage reference.

Each retain must have a release. Too many releases and your app will crash, too many retains and it will leak memory.
Use only if you really know what you are doing.

CIImageMBS.scaleTo(width as Integer, height as Integer) as CIImageMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreImage MBS MacCI Plugin 21.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Scales picture to target size.
Example
Dim pic As Picture = LogoMBS(500)
Dim image As CIImageMBS = CIImageMBS.imageWithPicture(pic)

Const targetWidth = 600.0
Const targetHeight = 400.0

#If mbs.VersionNumber < 21.2 Then

Dim filter As New CIFilterLanczosScaleTransformMBS

Dim scale As Double = targetHeight / image.Extent.Height
Dim aspect As Double = targetWidth / (image.Extent.Width * scale)

filter.inputImage = image
filter.inputScale = scale
filter.inputAspectRatio = aspect

Dim outputImage As CIImageMBS = filter.outputImage

#Else

Dim outputImage As CIImageMBS = image.scaleTo(targetWidth, targetHeight)

#EndIf

Dim result As Picture = outputImage.RenderPicture
Backdrop = result

We use CILanczosScaleTransform filter internally like in the example code for older plugin versions.

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


The biggest plugin in space...