Click here to Skip to main content
15,885,863 members
Articles / Desktop Programming / WPF

Image Processing is Done using WPF

Rate me:
Please Sign up or sign in to vote.
4.84/5 (19 votes)
6 Aug 2011CPOL6 min read 105K   16.2K   68  
Image Processing is done in a WPF application with some basic functionalities
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace ImageProcessingWPF4
{
    /// <summary>
    /// Interaction logic for BitmapViewWindow.xaml
    /// </summary>
    public partial class BitmapViewWindow : Window
    {
        CurrentImageHandler currImageHandler;

        public BitmapViewWindow(CurrentImageHandler currImageHandler)
        {
            InitializeComponent();
            this.currImageHandler = currImageHandler;
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            currImageHandler.CurrentBitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
            stream.Position = 0;
            byte[] data = new byte[stream.Length];
            stream.Read(data, 0, Convert.ToInt32(stream.Length));
            BitmapImage bmapImage = new BitmapImage();
            bmapImage.BeginInit();
            bmapImage.StreamSource = stream;
            bmapImage.EndInit();
            MainImage.Source = bmapImage;
            MainImage.Stretch = Stretch.Uniform;
        }

        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
            this.Close();
        }

        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            this.Close();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions