Xojo Conferences
XDCMay2019MiamiUSA
MBSOct2019CologneDE

Platforms to show: All Mac Windows Linux Cross-Platform

CGImageDestinationMBS.AddImage(image as CGImageMBS, properties as dictionary=nil)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 9.5 Yes No No Yes, macOS only No
Function: 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
Notes:
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.

Feedback, Comments & Corrections

CGImageDestinationMBS.AddImageCF(image as CGImageMBS, properties as Variant = nil)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 13.5 Yes No No Yes, macOS only No
Function: Adds an image to an image destination.
Notes:
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.

Feedback, Comments & Corrections

CGImageDestinationMBS.AddImageFromSource(source as CGImageSourceMBS, index as Integer, options as dictionary = nil)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 9.5 Yes No No Yes, macOS only No
Function: Adds an image from an image source to an image destination.
Notes:
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.

Feedback, Comments & Corrections

CGImageDestinationMBS.AddImageFromSourceCF(source as CGImageSourceMBS, index as Integer, options as Variant = nil)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 13.5 Yes No No Yes, macOS only No
Function: Adds an image from an image source to an image destination.
Notes:
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.

Feedback, Comments & Corrections

CGImageDestinationMBS.Constructor(file as folderitem, type as string, count as Integer = 1)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 9.5 Yes No No Yes, macOS only No
Function: Creates an image destination that writes to a location specified by a folderitem.
Notes:
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:

Feedback, Comments & Corrections

CGImageDestinationMBS.Constructor(type as string, count as Integer = 1)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 9.5 Yes No No Yes, macOS only No
Function: Creates an image destination that writes to a string.
Notes:
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:

Feedback, Comments & Corrections

CGImageDestinationMBS.Constructor(url as string, type as string, count as Integer = 1)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 9.5 Yes No No Yes, macOS only No
Function: Creates an image destination that writes to a location specified by a URL.
Notes:
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:

Feedback, Comments & Corrections

CGImageDestinationMBS.Data as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 9.5 Yes No No Yes, macOS only No
Function: Makes a copy of the data.
Notes: The data is collected and after you called Finalize you can pick the data here.

Feedback, Comments & Corrections

CGImageDestinationMBS.Finalize as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 9.5 Yes No No Yes, macOS only No
Function: 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
Notes:
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.

Feedback, Comments & Corrections

CGImageDestinationMBS.FinalizeMT as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 13.1 Yes No No Yes, macOS only No
Function: Writes image data and properties to the data or URL associated with the image destination.
Notes:
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.
Must be called inside a Xojo (Xojo) thread so time yields to main thread and you can keep the GUI running.

Feedback, Comments & Corrections

CGImageDestinationMBS.SetProperties(options as dictionary = nil)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 9.5 Yes No No Yes, macOS only No
Function: 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
Notes: Available in Mac OS X version 10.4 and later.

Feedback, Comments & Corrections

CGImageDestinationMBS.SetPropertiesCF(options as Variant)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 13.5 Yes No No Yes, macOS only No
Function: Applies one or more properties to all images in an image destination.
Notes:
Available in Mac OS X version 10.4 and later.
Options can be a Dictionary or CFDictionaryMBS.

Feedback, Comments & Corrections

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




Links
MBS Xojo tutorial videos