Commands
The commands of RadImageEditor allows you to execute actions over the image element, like rotate, flip, undo and more.
The RadImageEditor commands apply an effect over the image or execute an action like undo, redo and open/save image. The commands are defined in the ImageEditorCommands
, ImageEditorRoutedCommands
and ImageCommands
classes.
ImageEditorCommands
An instance of the ImageEditorCommands
class is created and assigned to the Commands
property of RadImageEditor
which can be used to access the commands. The ImageEditorCommands
instance is associated with the corresponding RadImageEditor
control and it executes the commands over its image.
Example 1: Using an image editor command in XAML
Example 2: Using an image editor command in code
ImageEditorCommands
class.
-
OpenImageCommand: Opens a dialog that allows you to select an image file which will get loaded into the corresponding
RadImageEditor
element. The CommandParameter of the command is optional and it expects a string describing the file extension filter of the file dialog.Example 3: Using OpenImageCommand
-
SaveImageCommand: Opens a dialog that allows you to select where on the file system the current image will get saved. The CommandParameter of the command is optional and it expects a string describing the file extension filter of the file dialog.
Example 4: Using SaveImageCommand
-
UndoCommand: Undo the last change applied to the image. This command doesn't use the CommandParameter.
Example 5: Using UndoCommand
-
RedoCommand: Executes a redo action over the current image. This command doesn't use the CommandParameter.
Example 6: Using RedoCommand
-
Rotate90ClockwiseCommand: Rotates the image by 90 degrees clockwise. This command doesn't use the CommandParameter.
Example 7: Using Rotate90ClockwiseCommand
-
Rotate90CounterclockwiseCommand: Rotates the image by 90 degrees clockwise. This command doesn't use the CommandParameter.
Example 8: Using Rotate90CounterclockwiseCommand
-
Rotate180Command: Rotates the image by 180 degrees clockwise. This command doesn't use the CommandParameter.
Example 9: Using Rotate180Command
-
InvertColorsCommand: Inverts the colors in the image. This command doesn't use the CommandParameter.
Example 10: Using InvertColorsCommand
-
FlipVerticalCommand: Flips the image vertically. This command doesn't use the CommandParameter.
Example 11: Using FlipVerticalCommand
-
FlipHorizontalCommand: Flips the image horizontally. This command doesn't use the CommandParameter.
Example 12: Using FlipHorizontalCommand
-
ExecuteToolCommand: Executes a tool. The CommandParameter is required and it expects an object of type ITool.
Example 13: Using ExecuteToolCommand
ImageCommands
The ImageCommands
class contains static commands that apply image adjustments like crop, blur, resize, draw, etc. The adjustments are executed via classes that implement the IImageCommand interface.
The actions in the ImageCommands
class are not dependent on the RadImageEditor control. Instead they work with an instance of RadBitmap which in the context of RadImageEditor
holds its current picture. Each command expects a RadBitmap
object and returns a modified copy after the corresponding adjustments are applied.
The following list shows the available commands in the ImageCommands
class.
-
FlipCommand: Flips the image horizontally or vertically. The context expected by the command is of type
FlipCommandContext
which contains information about the flip orientation.Example 14: Using ExecuteToolCommand
The command also provide two public static methods that can be used instead of theExecute
method.Example 15: Using FlipCommand static methods
-
RotateCommand: Rotates the image by the specified degree. The context expected by the command is of type
RotateCommandContext
which contains information about the rotation degrees and the color of the background that will be shown behind the rotated image.Example 16: Using RotateCommand
-
ContrastCommand: Changes the contrast and brightness of the image. The context expected by the command is of type
ContrastCommandContext
which contains information about the level of brightness and contrast that will be applied over the image. The default brightness is 0 and the allowed values are between -1 and 1. The default contrast is 1.5 and the allowed values are between 0 and 2.Example 17: Using ContrastCommand
-
BlurCommand: Applies a blur effect over the image. The context expected by the command is of type
BlurCommandContext
which contains information about the blur amount and the input size.Example 18: Using BlurCommand
-
SharpenCommand: Sharpens the image. The context expected by the command is of type
SharpenCommandContext
which contains information about the blur amount and the input size.Example 19: Using SharpenCommand
-
HueShiftCommand: Applies a hue shift effect over the image. The context expected by the command is of type
HueShiftCommandContext
which contains information about hue offset.Example 20: Using HueShiftCommand
-
InvertColorsCommand: Inverts the colors in the image. This command doesn't use a context object.
Example 21: Using InvertColorsCommand
-
SaturationCommand: Applies saturation to the image. The context expected by the command is of type
SaturationCommandContext
which contains information about saturation.Example 22: Using SaturationCommand
-
CropCommand: Crops the image. The context expected by the command is of type
CropCommandContext
which contains information about the top left position where the crop starts and the final size of the cropped image.Example 23: Using CropCommand
-
ResizeCommand: Resizes the image. The context expected by the command is of type
ResizeCommandContext
which contains information about the new width and height of the image.Example 24: Using ResizeCommand
-
CanvasResizeCommand: Resizes the canvas. The context expected by the command is of type
CanvasResizeCommandContext
which contains information about the image alignment, the new size of the canvas and the background color.Example 25: Using CanvasResizeCommand
-
RoundCornersCommand: Adds round corners around the image. The context expected by the command is of type
RoundCornersCommandContext
which contains information about the corner radius, the border and the background.Example 26: Using RoundCornersCommandd
-
DrawTextCommand: Draws text over the image. The context expected by the command is of type
DrawTextCommandContext
which contains information about text and its position.Example 27: Using DrawTextCommand
-
DrawCommand: Draws a shape path over the image. The context expected by the command is of type
DrawCommandContext
which contains information about the drawn path.Example 28: Using DrawCommand
ImageEditorRoutedCommands
The ImageEditorRoutedCommands class contains static RoutedCommands which wrap few of the commands of the ImageEditorCommands class.
The following list shows the available commands in the ImageEditorRoutedCommands
class.
FlipHorizontal
FlipVertical
Rotate90Clockwise
Rotate90Counterclockwise
InvertColors
ExecuteTool
Undo
Redo
Open
Save
Example 29: Using the ImageEditorRoutedCommands
xmlns:commands="clr-namespace:Telerik.Windows.Media.Imaging.ImageEditorCommands.RoutedCommands;assembly=Telerik.Windows.Controls.ImageEditor"
.