Platforms to show: All Mac Windows Linux Cross-Platform

Back to CGImageDestinationMBS class.

CGImageDestinationMBS.AddImage(image as CGImageMBS, properties as dictionary=nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 9.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Adds an image to an image destination.
Example
dim inputfile as FolderItem = SpecialFolder.Desktop.Child("test.jpg")

// reading the picture
dim c as new CGImageSourceMBS(inputfile)
dim img as CGImageMBS = c.CreateImageAtIndex(0)
dim propertiesGlobal as Dictionary = c.Properties
dim propertiesImage as Dictionary = c.PropertiesAtIndex(0)

dim outputFile as FolderItem = SpecialFolder.Desktop.Child("output.jpg")
dim d as new CGImageDestinationMBS(outputFile, "public.jpeg", 1)

// writing the picture and include metadata
d.SetProperties(propertiesGlobal)
d.AddImage(img, propertiesImage)
if d.FinalizeMT then
outputFile.Launch
else
MsgBox "Failed to write jpeg."
end if

image: The image to add.
properties: An optional dictionary that specifies the properties of the added image.

For properties you can use those in the CGImageSourceMBS class, kCGImageDestinationLossyCompressionQuality and kCGImageDestinationBackgroundColor.

The function logs an error if you add more images than what you specified when you created the image destination.
Available in Mac OS X version 10.4 and later.

CGImageDestinationMBS.AddImageCF(image as CGImageMBS, properties as Variant = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 13.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Adds an image to an image destination.

image: The image to add.
properties: An optional dictionary or CFDictionaryMBS that specifies the properties of the added image.

For properties you can use those in the CGImageSourceMBS class, kCGImageDestinationLossyCompressionQuality and kCGImageDestinationBackgroundColor.

The function logs an error if you add more images than what you specified when you created the image destination.
Available in Mac OS X version 10.4 and later.

CGImageDestinationMBS.AddImageFromSource(source as CGImageSourceMBS, index as Integer, options as dictionary = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 9.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Adds an image from an image source to an image destination.

source: An image source.
index: An index that specifies the location of the image in the image source. The index is zero-based.
properties: A dictionary that specifies properties to overwrite or add to the source image properties.

Available in Mac OS X version 10.4 and later.

Some examples using this method:

CGImageDestinationMBS.AddImageFromSourceCF(source as CGImageSourceMBS, index as Integer, options as Variant = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 13.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Adds an image from an image source to an image destination.

source: An image source.
index: An index that specifies the location of the image in the image source. The index is zero-based.
properties: A dictionary or CFDcitionaryMBS that specifies properties to overwrite or add to the source image properties.

Available in Mac OS X version 10.4 and later.

CGImageDestinationMBS.Constructor(file as folderitem, type as string, count as Integer = 1)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 9.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates an image destination that writes to a location specified by a folderitem.
Example
Dim p As Picture = LogoMBS(500)

// save as Photoshop

Dim image As CGImageMBS = CGImageMBS.CreateImage(p)
Dim file1 As FolderItem = SpecialFolder.Desktop.Child("test1.psd")
Dim dest As New CGImageDestinationMBS(file1, "com.adobe.photoshop-image", 1)

dest.AddImage(image, Nil)

If dest.Finalize Then
// MsgBox "Saved"
Else
MsgBox "Failed to save."
End If

file: The file to write to. If the file already exists, the data at this location is overwritten.

type: The UTI (uniform type identifier) of the resulting image file. See Uniform Type Identifiers Overview for a list of system-declared and third-party UTIs.

count: The number of images (not including thumbnail images) that the image file will contain.

On success the handle value is not zero.

Available in Mac OS X version 10.4 and later.

See also:

CGImageDestinationMBS.Constructor(type as string, count as Integer = 1)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 9.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates an image destination that writes to a string.

type: The uniform type identifier (UTI) of the resulting image file. See Uniform Type Identifiers Overview for a list of system-declared and third-party UTIs.

count: The number of images (not including thumbnail images) that the image file will contain.

On success the handle is not zero.

Available in Mac OS X version 10.4 and later.

See also:

CGImageDestinationMBS.Constructor(url as string, type as string, count as Integer = 1)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 9.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Creates an image destination that writes to a location specified by a URL.

url: The URL to write to. If the URL already exists, the data at this location is overwritten.

type: The UTI (uniform type identifier) of the resulting image file. See Uniform Type Identifiers Overview for a list of system-declared and third-party UTIs.

count: The number of images (not including thumbnail images) that the image file will contain.

On success the handle value is not zero.

Available in Mac OS X version 10.4 and later.

See also:

CGImageDestinationMBS.Data as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 9.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Makes a copy of the data.

The data is collected and after you called Finalize you can pick the data here.

CGImageDestinationMBS.Finalize as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 9.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Writes image data and properties to the data or URL associated with the image destination.
Example
dim logo as Picture = LogoMBS(500)
dim image as CGImageMBS = CGCreateImageMBS(logo)

dim file as FolderItem = SpecialFolder.Desktop.Child("logo.png")
dim d as new CGImageDestinationMBS(file, "public.png", 1)

d.AddImage(image, nil)

if d.Finalize then
MsgBox "Saved"
else
MsgBox "Failed to save."
end if

Returns true if the image is successfully written; false otherwise.

You must call this function or the output of the image destination will not be valid. After calling this function, no additional data can be added to the image destination.

Available in Mac OS X version 10.4 and later.

CGImageDestinationMBS.FinalizeMT as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 13.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Writes image data and properties to the data or URL associated with the image destination.

Returns true if the image is successfully written; false otherwise.

You must call this function or the output of the image destination will not be valid. After calling this function, no additional data can be added to the image destination.

Available in Mac OS X version 10.4 and later.

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.

CGImageDestinationMBS.SetProperties(options as dictionary = nil)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 9.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Applies one or more properties to all images in an image destination.
Example
dim inputfile as FolderItem = SpecialFolder.Desktop.Child("test.jpg")

// reading the picture
dim c as new CGImageSourceMBS(inputfile)
dim img as CGImageMBS = c.CreateImageAtIndex(0)
dim propertiesGlobal as Dictionary = c.Properties
dim propertiesImage as Dictionary = c.PropertiesAtIndex(0)

dim outputFile as FolderItem = SpecialFolder.Desktop.Child("output.jpg")
dim d as new CGImageDestinationMBS(outputFile, "public.jpeg", 1)

// writing the picture and include metadata
d.SetProperties(propertiesGlobal)
d.AddImage(img, propertiesImage)
if d.FinalizeMT then
outputFile.Launch
else
MsgBox "Failed to write jpeg."
end if

Available in Mac OS X version 10.4 and later.

CGImageDestinationMBS.SetPropertiesCF(options as Variant)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method CoreGraphics MBS MacCG Plugin 13.5 ✅ Yes ❌ No ❌ No ✅ Yes All
Applies one or more properties to all images in an image destination.

Available in Mac OS X version 10.4 and later.
Options can be a Dictionary or CFDictionaryMBS.

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


The biggest plugin in space...