命令
RadImageEditor的命令允许您在图像元素上执行操作,如旋转、翻转、撤消等。
RadImageEditor命令在图像上应用效果或执行诸如撤消、重做和打开/保存图像之类的操作。命令定义在ImageEditorCommands
,ImageEditorRoutedCommands
而且ImageCommands
类。
ImageEditorCommands
的实例ImageEditorCommands
类创建并分配给命令
的属性RadImageEditor
可以用来访问命令。的ImageEditorCommands
实例与相应的实例相关联RadImageEditor
控件,并对其映像执行命令。
例1:在XAML中使用图像编辑器命令
<网格> <网格。RowDefinitions> < / >
例2:在代码中使用图像编辑器命令
this.radImageEditor.Commands.Open.Execute(空);
ImageEditorCommands
类。OpenImageCommand:打开一个对话框,允许您选择一个将被加载到相应的图像文件
RadImageEditor
元素。命令的CommandParameter是可选的,它需要一个字符串来描述文件扩展名过滤器文件对话框的。例3:使用OpenImageCommand
this.radImageEditor.Commands.Open。执行“图像文件(bmp格式;jpg;gif) |bmp格式;jpg;|所有文件(.) |.”);
SaveImageCommand:打开一个对话框,允许您选择当前映像将保存在文件系统的何处。命令的CommandParameter是可选的,它需要一个字符串来描述文件扩展名过滤器文件对话框的。
例4:使用SaveImageCommand
this.radImageEditor.Commands.Save。执行“图像文件(bmp格式;jpg;gif) |bmp格式;jpg;|所有文件(.) |.”);
UndoCommand:撤销应用到映像的最后一次更改。这个命令不使用CommandParameter。
例5:使用UndoCommand
this.radImageEditor.Commands.Undo.Execute(空);
RedoCommand:对当前映像执行重做操作。这个命令不使用CommandParameter。
例6:使用RedoCommand
this.radImageEditor.Commands.Undo.Execute(空);
Rotate90ClockwiseCommand:顺时针旋转图像90度。这个命令不使用CommandParameter。
例7:使用Rotate90ClockwiseCommand
this.radImageEditor.Commands.Rotate90Clockwise.Execute(空);
Rotate90CounterclockwiseCommand:顺时针旋转图像90度。这个命令不使用CommandParameter。
例8:使用Rotate90CounterclockwiseCommand
this.radImageEditor.Commands.Rotate90Counterclockwise.Execute(空);
Rotate180Command:顺时针旋转图像180度。这个命令不使用CommandParameter。
例9:使用rotate180命令
this.radImageEditor.Commands.Rotate180.Execute(空);
InvertColorsCommand:将图像中的颜色颠倒。这个命令不使用CommandParameter。
例10:使用InvertColorsCommand
this.radImageEditor.Commands.InvertColors.Execute(空);
FlipVerticalCommand:垂直翻转图像。这个命令不使用CommandParameter。
例11:使用FlipVerticalCommand
this.radImageEditor.Commands.FlipVertical.Execute(空);
FlipHorizontalCommand:水平翻转图像。这个命令不使用CommandParameter。
例12:使用FlipHorizontalCommand
this.radImageEditor.Commands.FlipHorizontal.Execute(空);
ExecuteToolCommand:执行工具.CommandParameter是必需的,它需要一个类型的对象ITool.
例13:使用ExecuteToolCommand
ITool工具=新的BlurTool();this.radImageEditor.Commands.ExecuteTool.Execute(工具);
ImageCommands
的ImageCommands
类包含静态命令,用于应用图像调整,如裁剪、模糊、调整大小、绘制等。类的类执行调整IImageCommand接口。
的操作ImageCommands
类不依赖于RadImageEditor控件。的实例RadBitmap在什么情况下RadImageEditor
保存当前图片。每个命令都需要一个RadBitmap
对象,并在应用相应的调整后返回修改后的副本。
下面的列表显示了可用命令在ImageCommands
类。
FlipCommand:水平或垂直翻转图像。命令所期望的上下文是类型的
FlipCommandContext
其中包含有关翻转方向的信息。例14:使用ExecuteToolCommand
var context =新FlipCommandContext(方向。垂直);RadBitmap newImage = ImageCommands.Flip.Execute(this.radImageEditor。图像、背景);this.radImageEditor.Image = newImage;
执行
方法。例15:使用FlipCommand静态方法
RadBitmap horizontallyFlippedImage = flipcommand . flihorizonzontal (this.radImageEditor.Image);RadBitmap verticallyFlippedImage = FlipCommand.FlipVertical(this.radImageEditor.Image);
RotateCommand:旋转图像到指定的角度。命令所期望的上下文是类型的
RotateCommandContext
包含旋转度和背景颜色的信息,将显示在旋转后的图像后面。例16:使用RotateCommand
var context = new RotateCommandContext(22, Colors.Green);RadBitmap newImage = ImageCommands.Rotate.Execute(this.radImageEditor。图像、背景);this.radImageEditor.Image = newImage;
ContrastCommand:改变图像的对比度和亮度。命令所期望的上下文是类型的
ContrastCommandContext
其中包含关于将应用于图像上的亮度和对比度级别的信息。默认亮度为0,允许的亮度值在-1到1之间。默认对比度为1.5,允许的值在0到2之间。例17:使用反差命令
var context = new contastcommandcontext(亮度:0.25,对比度:0.25);RadBitmap newImage = ImageCommands.Contrast.Execute(this.radImageEditor. exe)图像、背景);this.radImageEditor.Image = newImage;
BlurCommand:在图像上应用模糊效果。命令所期望的上下文是类型的
BlurCommandContext
其中包含关于模糊量和输入大小的信息。例18:使用BlurCommand
var context = new BlurCommandContext(0.5, new Size(500, 500));RadBitmap newImage = ImageCommands.Blur.Execute(this.radImageEditor。图像、背景);this.radImageEditor.Image = newImage;
SharpenCommand:锐化图像。命令所期望的上下文是类型的
SharpenCommandContext
其中包含关于模糊量和输入大小的信息。例19:使用SharpenCommand
var originalImage = this.radImageEditor.Image;var context = new SharpenCommandContext(0.5, new Size(originalImage. Size)。宽度,originalImage.Height));RadBitmap newImage = imagecommands .锐化。执行(originalImage之下、上下文);this.radImageEditor.Image = newImage;
HueShiftCommand:在图像上应用色相偏移效果。命令所期望的上下文是类型的
HueShiftCommandContext
其中包含有关色相偏移的信息。例20:使用HueShiftCommand
var context = new HueShiftCommandContext(40);RadBitmap newImage = imagecommands . hushift . execute (this.radImageEditor。图像、背景);this.radImageEditor.Image = newImage;
InvertColorsCommand:将图像中的颜色颠倒。这个命令不使用上下文对象。
例21:使用InvertColorsCommand
RadBitmap newImage = ImageCommands.InvertColors.Execute(this.radImageEditor。形象,null);this.radImageEditor.Image = newImage;
SaturationCommand:对图像应用饱和度。命令所期望的上下文是类型的
SaturationCommandContext
它包含了饱和度的信息。例22:使用SaturationCommand
var context = new SaturationCommandContext(40);RadBitmap newImage = ImageCommands.Saturation.Execute(this.radImageEditor。图像、背景);this.radImageEditor.Image = newImage;
CropCommand:裁剪图像。命令所期望的上下文是类型的
CropCommandContext
其中包含关于裁剪开始的左上角位置和裁剪图像的最终大小的信息。例23:使用CropCommand
var context = new CropCommandContext(10,10,250,250);RadBitmap newImage = ImageCommands.Crop.Execute(this.radImageEditor。图像、背景);this.radImageEditor.Image = newImage;
ResizeCommand:调整镜像大小。命令所期望的上下文是类型的
ResizeCommandContext
其中包含关于图像的新宽度和高度的信息。例24:使用ResizeCommand命令
var context = new ResizeCommandContext(250, 250);RadBitmap newImage = ImageCommands.Resize.Execute(this.radImageEditor。图像、背景);this.radImageEditor.Image = newImage;
CanvasResizeCommand:调整画布的大小。命令所期望的上下文是类型的
CanvasResizeCommandContext
其中包含关于图像对齐、画布的新大小和背景颜色的信息。例25:使用CanvasResizeCommand
var context = new CanvasResizeCommandContext(颜色。绿色HorizontalAlignment。离开了,VerticalAlignment。Top, 250, 250);RadBitmap newImage = ImageCommands.CanvasResize.Execute(this.radImageEditor。图像、背景);this.radImageEditor.Image = newImage;
RoundCornersCommand:在图像周围添加圆角。命令所期望的上下文是类型的
RoundCornersCommandContext
其中包含关于角半径,边界和背景的信息。例26:使用roundcornerscommand
var context = new round拐角commandcontext(10,颜色。绿色,2,Colors.Black);RadBitmap newImage = ImageCommands.RoundCorners.Execute(this.radImageEditor。图像、背景);this.radImageEditor.Image = newImage;
DrawTextCommand:在图像上绘制文本。命令所期望的上下文是类型的
DrawTextCommandContext
它包含关于文本及其位置的信息。例27:使用DrawTextCommand
var context = new DrawTextCommandContext(16,颜色。绿色,"My text", new Point(100,100), 0);RadBitmap newImage = ImageCommands.DrawText.Execute(this.radImageEditor。图像、背景);this.radImageEditor.Image = newImage;
DrawCommand:在图像上绘制形状路径。命令所期望的上下文是类型的
DrawCommandContext
其中包含绘制路径的信息。例28:使用DrawCommand
var path = new path ();路径。Data = new EllipseGeometry(new Point(100,100), 10,10);路径。填充=画笔。绿色;路径。笔画=画笔。红色;路径。StrokeThickness = 3;var requiredParent = new Grid(); requiredParent.Children.Add(path); var context = new DrawCommandContext(path); RadBitmap newImage = ImageCommands.Draw.Execute(this.radImageEditor.Image, context); this.radImageEditor.Image = newImage;
ImageEditorRoutedCommands
的ImageEditorRoutedCommands类包含静态RoutedCommands哪个包装的几个命令ImageEditorCommands类。
下面的列表显示了可用命令在ImageEditorRoutedCommands
类。
FlipHorizontal
FlipVertical
Rotate90Clockwise
Rotate90Counterclockwise
InvertColors
ExecuteTool
撤销
重做
开放
保存
例29:使用ImageEditorRoutedCommands
.
xmlns:命令= " clr-namespace: Telerik.Windows.Media.Imaging.ImageEditorCommands.RoutedCommands;装配= Telerik.Windows.Controls.ImageEditor”
.