图像处理控件ImageGear for .NET教程:C# WPF应用程序创建示例(3)

     在前面的《图像处理控件ImageGear for .NET教程: C# WPF应用程序创建示例(2)》一文中已经讲解了如何在ImageGear for .NET中已经介绍了开发应用程序的五个步骤,本文将完成开发应用程序的步骤。

六、在去的放大菜单项目而创建的处理程序中,添加的代码到程序中。

if (null != imGearPageDisplay && !imGearPageDisplay.Page.DIB.IsEmpty())
{
    // Get the current zoom info
    ImGearZoomInfo igZoomInfo = imGearPageDisplay.GetZoomInfo(imGearPageView1);
    
    // Increase the zoom
    igZoomInfo.Horizontal.Value = igZoomInfo.Horizontal.Value * 1.25;
    igZoomInfo.Vertical.Value = igZoomInfo.Vertical.Value * 1.25;
    igZoomInfo.Horizontal.Fixed = true;
    igZoomInfo.Vertical.Fixed = true;
    
    // Set the new zoom values and repaint the view
    imGearPageDisplay.UpdateZoomFrom(igZoomInfo);
    imGearPageView1.Invalidate();
}

七、添加下面的代码到缩小单击处理程序。

if (null != imGearPageDisplay && !imGearPageDisplay.Page.DIB.IsEmpty())
{
    // Get the current zoom info
    ImGearZoomInfo igZoomInfo = imGearPageDisplay.GetZoomInfo(imGearPageView1);
    
    igZoomInfo.Horizontal.Value = igZoomInfo.Horizontal.Value * (1/1.25);
    igZoomInfo.Vertical.Value = igZoomInfo.Vertical.Value * (1/1.25);
    igZoomInfo.Horizontal.Fixed = true;
    igZoomInfo.Vertical.Fixed = true;
    // Set the new zoom values and repaint the view
    imGearPageDisplay.UpdateZoomFrom(igZoomInfo);
    imGearPageView1.Invalidate();
}

八、在Rotate 90点击处理应用程序中添加下面的代码。

if (null != imGearPageDisplay && null != imGearPage && !imGearPageDisplay.Page.DIB.IsEmpty())
    try
    {
        ImGearProcessing.Rotate(imGearPage, ImGearRotationValues.VALUE_90);
        imGearPageView1.Invalidate();
    }
    catch (ImGearException ex)
    {
        Debug.WriteLine(ex.Message);
    }

九、对于Rotate 180以及Rotate 270菜单项目的点击处理应用程序和上面的是一样的,除了量旋转分别是GearRotationValues.VALUE_180以及ImGearRotationValues.VALUE_270。

十、最后,点击“退出”菜单项的代码,如下所示:

this.Close();

十一、现在可以编译和运行完成的应用程序了。

图像处理控件ImageGear for .NET教程:C# WPF应用程序创建示例(3)

猜你喜欢

转载自susanhoho.iteye.com/blog/1943152