ZirconCropper is a control that allows the user to zoom and crop an image.


This control requires Xojo 2019r3.2 and Artisan Kit 1.2.2. Only desktop projects are supported.


Open the binary project and copy both the ZirconCropper class and ArtisanKit module into your project. If you already use Artisan Kit and encounter compile errors with the control, your ArtisanKit module needs to be updated to the included version.


Event SourceImagePresented (Source As Picture)

This event triggers when the source image is changed. The Source parameter may be nil, such as when the Clear method is called.

Event SourceImagePresenting (Source As Picture)

This event triggers just before the source image is changed. The Source parameter will never be nil. Feel free to make changes to the image, but do not replace the value of the Source parameter.


BackgroundColor As Color

Set the background color of the control. Frame and zoom controls will automatically adjust their colors based on the background color. The background color is not applied to the cropped images.

HasBackgroundColor As Boolean

By default the control will draw be transparent. Set this to true to have the control's background filled with the color specified by the BackgroundColor property.


Sub Clear ()

Call this method to reset the cropper to its default state. This will trigger the SourceImagePresented event, but not the SourceImagePresenting event.

Function Crop () As Picture

After you have supplied a picture and desired size using the Present method, the Crop method returns the cropped image as a multi-resolution picture.

Sub Present (Source As Picture, DesiredWidth As Integer, DesiredHeight As Integer)

Sets the cropper to display the Source parameter to be cropped to DesiredWidth and DesiredHeight.

Sub Update (Source As Picture)

Allows immediately setting the displayed image without changing anything else, such as the zoom level. The SourceImagePresenting and SourceImagePresented events will not fire.