Working With Images Using Visual Studio

Take the following steps to create and run a program to add an image containing special effects using LEADTOOLS ImageViewer object in Visual Studio.

  1. Start Visual Studio.
  2. Choose File->New->Project... from the menu.
  3. In the New Project dialog box, choose "Project Types-->Visual C# Projects-->NET Framework 3.0".  Then choose "Templates-->Windows Application (WPF)".
  4. Type the project name as "ImageViewerEffects" in the Project Name field, and then click OK. If desired, type a new location for your project or select a directory using the Browse button, and then click OK.
  5. In the "Solution Explorer" window, right-click on the "References" folder, and select "Add Reference..." from the context menu. In the "Add Reference..." dialog box, select the "Browse" tab and browse to LEAD Technologies For .NET "C:\LEADTOOLS 19\Bin\DotNet\Win32 " folder and select the following DLLs:

    • Leadtools.dll
    • Leadtools.Codecs.dll
    • Leadtools.ImageProcessing.SpecialEffects.dll
    • Leadtools.Windows.Controls.dll
    • Leadtools.Windows.Media.dll
    • Leadtools.Windows.Media.Effects.dll Click Select and then click OK to add the above DLLs to the application.
  6. Set Window1.xaml to horizontal split for easy viewing of the XAML code. The following steps involve inserting XAML code snippets into the source code of Window1.xaml. The source code provided is intended to build an application in Visual Studio and Expression Blend.

  7. Display an image. Loading an image simply requires adding the following XAML code to the source.  Make sure you remove any source code loaded by default into the window.

[Window1.xaml]

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    x:Class="ImageViewerEffects.Window1" 
    x:Name="Window" 
    Title="ImageViewerEffects"  
    Width="640" 
    Height="480" 
    xmlns:Leadtools_Windows_Controls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls"> 
    <Grid x:Name="LayoutRoot"> 
        <Leadtools_Windows_Controls:ImageViewer Margin="124,132,205,124" Content="ImageViewer" SizeMode="Stretch"> 
            <Leadtools_Windows_Controls:ImageViewer.Source> 
                <BitmapImage UriSource="<LEADTOOLS_INSTALLDIR>\Images\ImageProcessingDemo\NaturalFruits.jpg"/> 
            </Leadtools_Windows_Controls:ImageViewer.Source> 
        </Leadtools_Windows_Controls:ImageViewer> 
    </Grid> 
</Window> 

  1. Build, and Run the program to test it.
  2. Image Effects - Magnifying Glass.  Loading an image and accessing the magnifying glass effect requires pasting the following XAML code. Make sure any other code is removed from the source window.

[Window1.xaml]

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    x:Class="ImageViewerEffects.Window1" 
    x:Name="Window" 
    Title="ImageViewerEffects" 
    Width="857" 
    Height="640" 
    xmlns:Leadtools_Windows_Controls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls"> 
        <Grid x:Name="LayoutRoot"> 
            <Leadtools_Windows_Controls:ImageViewer 
                Margin="24,-1,25,9" 
                Content="ImageViewer" 
                SizeMode="Stretch" 
                InteractiveMode="MagnifyGlass" 
                InteractiveGeometryType="Rectangle" 
                 ScaleFactor="3"> 
                    <Leadtools_Windows_Controls:ImageViewer.Source> 
                        <BitmapImage UriSource="<LEADTOOLS_INSTALLDIR>\Images\ImageProcessingDemo\NaturalFruits.jpg"/> 
                    </Leadtools_Windows_Controls:ImageViewer.Source> 
                </Leadtools_Windows_Controls:ImageViewer> 
            </Grid> 
       </Window> 

  1. Build, and Run the program to test it.
  2.  Image Effects - Colored balls. Loading an image and accessing the colored balls special effects requires pasting the following XAML code. Make sure any other code is removed from the source window.

[Window1.xaml]

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:Leadtools_Windows_Controls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls" 
x:Class="ImageViewerEffects.Window1" 
x:Name="Window" 
Title="ImageViewerEffects" 
Width="640" 
Height="480" 
xmlns:Leadtools_Windows_Media_Effects_SpecialEffects="clr-namespace:Leadtools.Windows.Media.Effects.SpecialEffects;assembly=Leadtools.Windows.Media.Effects"> 
    <Grid x:Name="LayoutRoot"> 
        <Leadtools_Windows_Controls:ImageViewer 
            Margin="124,132,205,124" 
            Content="ImageViewer" 
            ScaleFactor="1" 
            SizeMode="Fit"> 
            <Leadtools_Windows_Controls:ImageViewer.Source> 
                <BitmapImage UriSource="C:/Program Files/LEAD Technologies/LEADTOOLS 15/Images/ImageProcessingDemo/NaturalFruits.jpg"/> 
            </Leadtools_Windows_Controls:ImageViewer.Source> 
            <Leadtools_Windows_Controls:ImageViewer.BitmapEffect> 
                <Leadtools_Windows_Media_Effects_SpecialEffects:ColoredBallsCommandBitmapEffect/> 
            </Leadtools_Windows_Controls:ImageViewer.BitmapEffect> 
        </Leadtools_Windows_Controls:ImageViewer> 
    </Grid> 
</Window> 

  1. Build, and Run the program to test it.
  2. Image List control.  To load images into an image list control, paste the following XAML code into the source window. Make sure any other source code is removed from the source window.

[Window1.xaml]

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    x:Class="ImageViewerEffects.Window1" 
    x:Name="Window" 
    Title="ImageViewerEffects" 
    Width="640" 
    Height="480" 
    xmlns:Leadtools_Windows_Controls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls"> 
        <Grid x:Name="LayoutRoot"> 
            <Leadtools_Windows_Controls:ImageList 
                HorizontalAlignment="Left" 
                Margin="78,130,0,153" 
                Width="178" 
                IsSynchronizedWithCurrentItem="True" 
                ScrollStyle="Horizontal" 
                ViewStyle="Button"> 
                <Leadtools_Windows_Controls:ImageListItem 
                Width="150" 
                Height="150" 
                Content="ImageListItem"> 
                    <Leadtools_Windows_Controls:ImageListItem.Image> 
                        <BitmapImage UriSource="C:/users/Public/Documents/LEADTOOLS Images/NaturalFruits.jpg"/> 
                        </Leadtools_Windows_Controls:ImageListItem.Image> 
                    </Leadtools_Windows_Controls:ImageListItem> 
                        <Leadtools_Windows_Controls:ImageListItem 
                            Width="148" 
                            Height="169" 
                            Content="ImageListItem"> 
                        <Leadtools_Windows_Controls:ImageListItem.Image> 
                           <BitmapImage UriSource="C:/users/Public/Documents/LEADTOOLS Images/ImageProcessingDemo/Ani.gif"/> 
                        </Leadtools_Windows_Controls:ImageListItem.Image> 
                    </Leadtools_Windows_Controls:ImageListItem> 
                <Leadtools_Windows_Controls:ImageListItem 
                    Width="147" 
                    Height="169" 
                    Content="ImageListItem" 
                    ViewStyle="Button"> 
                    <Leadtools_Windows_Controls:ImageListItem.Image> 
                        <BitmapImage UriSource="C:/users/Public/Documents/LEADTOOLS Images/Image2.jpg"/> 
                    </Leadtools_Windows_Controls:ImageListItem.Image> 
                </Leadtools_Windows_Controls:ImageListItem> 
            </Leadtools_Windows_Controls:ImageList> 
        </Grid> 
</Window> 

  1. Build, and Run the program to test it. 

Programming Reference

Adding LEADTOOLS Controls to Microsoft Expression Blend Display Images Using Expression Blend Creating Image Lists Using Expression Blend Link an Image List to an Image Viewer Using Expression Blend Add a Magnifying Glass Using Expression Blend Adding Bitmap Effects Using Expression Blend

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Imaging, Medical, and Document
Click or drag to resize