Import/Export
RadImageEditor can load and save images in different file formats. This functionality is implemented through format providers. The format providers shipped with the control are:
PngFormatProvider: allows import and export from/to PNG;
BmpFormatProvider: allows import and export from/to BMP;
JpegFormatProvider: allows import only from JPEG/JPG.
As RadImageEditor is highly extensible, you can create your own format providers by implementing the IImageFormatProvider interface. This approach is illustrated in a demo attached to this blog post, showing how a format provider that supports both import and export from JPEG can be developed and plugged in RadImageEditor’s architecture.
The format providers can load images from streams and bytes just like shown in Example 1.
Example 1: Load an image
The code from Example 2 loads an image from a file using the open file dialog.
Example 2: Load an image through the OpenFileDialog
You can use the available format providers to export the images as well. Example 3 shows how you can get the image of the editor, encode it in a specific format – BMP or PNG, and save it using the SaveFileDialog.
Example 3: Save an image through the SaveFileDialog
One thing to note is that the last applied change may not be committed (which normally happens when you press Enter or change the current tool).
To commit this last change, use the method from Example 4