Click here to Skip to main content
Click here to Skip to main content
Articles » Multimedia » GDI+ » General » Downloads
 
Add your own
alternative version

Image Processing Lab in C#

, 13 Mar 2007 GPL3
A tool and library for image processing
iplab_demo.zip
iplab_demo
AForge.dll
AForge.Imaging.chm
AForge.Imaging.dll
AForge.Math.dll
DockingToolbar.dll
iplab.exe
SourceGrid2.dll
SourceLibrary.dll
WeifenLuo.WinFormsUI.dll
iplab_src.zip
iplab_src
icons
about.gif
clone.gif
convolution.gif
copy.gif
cut.gif
disk.gif
fit_to_size.gif
folder_out.gif
fourier.gif
grayscale.gif
histogram_window.gif
levels.gif
morphology.gif
paste.gif
pie-chart.gif
resize.gif
rotate.gif
threshold.gif
view_1_1.gif
zoom_in.gif
zoom_out.gif
iplab
App.ico
banner.gif
column-chart.ico
Controls
Filters Forms
line-chart.ico
References
AForge.dll
AForge.Imaging.dll
AForge.Math.dll
DockingToolbar.dll
SourceGrid2.dll
SourceLibrary.dll
WeifenLuo.WinFormsUI.dll
Resources
arrow.bmp
harrow.cur
hmove.cur
Tools
// Image Processing Lab
//
// Copyright � Andrew Kirillov, 2005
// andrew.kirillov@gmail.com
//

namespace IPLab
{
    using System;
    using System.Drawing;
    using System.IO;
    using System.Xml;
    using System.Text;
    using System.Windows.Forms;

    /// <summary>
    /// Application configuration
    /// </summary>
    public class Configuration
    {
        public Point mainWindowLocation = new Point( 100, 50 );
        public Size mainWindowSize = new Size( 800, 600 );

        public bool histogramVisible = false;
        public bool statisticsVisible = false;

        public bool openInNewDoc = false;
        public bool rememberOnChange = false;

        // Constructor
        public Configuration( )
        {
        }

        // Save configureation to file
        public void Save( string fileName )
        {
            // open file
            FileStream fs = new FileStream( fileName, FileMode.Create );
            // create XML writer
            XmlTextWriter xmlOut = new XmlTextWriter( fs, Encoding.Unicode );

            // use indenting for readability
            xmlOut.Formatting = Formatting.Indented;

            // start document
            xmlOut.WriteStartDocument( );
            xmlOut.WriteComment( "IPLab configuration file" );

            // main node
            xmlOut.WriteStartElement( "IPLab" );

            // position node
            xmlOut.WriteStartElement( "Position" );
            xmlOut.WriteAttributeString( "x", mainWindowLocation.X.ToString( ) );
            xmlOut.WriteAttributeString( "y", mainWindowLocation.Y.ToString( ) );
            xmlOut.WriteAttributeString( "width", mainWindowSize.Width.ToString( ) );
            xmlOut.WriteAttributeString( "height", mainWindowSize.Height.ToString( ) );
            xmlOut.WriteEndElement( );

            // settings node
            xmlOut.WriteStartElement( "Settings" );
            xmlOut.WriteAttributeString( "histogram", histogramVisible.ToString( ) );
            xmlOut.WriteAttributeString( "statistics", statisticsVisible.ToString( ) );
            xmlOut.WriteAttributeString( "newOnChange", openInNewDoc.ToString( ) );
            xmlOut.WriteAttributeString( "rememberOnChange", rememberOnChange.ToString( ) );
            xmlOut.WriteEndElement( );

            xmlOut.WriteEndElement( );

            // close file
            xmlOut.Close( );
        }

        // Load configureation from file
        public bool Load( string fileName )
        {
            bool ret = false;

            // check file existance
            if ( File.Exists( fileName ) )
            {
                FileStream fs = null;
                XmlTextReader xmlIn = null;

                try
                {
                    // open file
                    fs = new FileStream( fileName, FileMode.Open );
                    // create XML reader
                    xmlIn = new XmlTextReader( fs );

                    xmlIn.WhitespaceHandling = WhitespaceHandling.None;
                    xmlIn.MoveToContent( );

                    // check for main node
                    if ( xmlIn.Name != "IPLab" )
                        throw new ApplicationException( "" );

                    // move to next node
                    xmlIn.Read( );
                    if ( xmlIn.NodeType == XmlNodeType.EndElement )
                        xmlIn.Read( );

                    // check for position node
                    if ( xmlIn.Name != "Position" )
                        throw new ApplicationException( "" );

                    // read main window position
                    int x = Convert.ToInt32( xmlIn.GetAttribute( "x" ) );
                    int y = Convert.ToInt32( xmlIn.GetAttribute( "y" ) );
                    int width = Convert.ToInt32( xmlIn.GetAttribute( "width" ) );
                    int height = Convert.ToInt32( xmlIn.GetAttribute( "height" ) );

                    mainWindowLocation = new Point( x, y );
                    mainWindowSize = new Size( width, height );

                    // move to next node
                    xmlIn.Read( );
                    if ( xmlIn.NodeType == XmlNodeType.EndElement )
                        xmlIn.Read( );

                    // check for position node
                    if ( xmlIn.Name != "Settings" )
                        throw new ApplicationException( "" );

                    histogramVisible = Convert.ToBoolean( xmlIn.GetAttribute( "histogram" ) );
                    statisticsVisible = Convert.ToBoolean( xmlIn.GetAttribute( "statistics" ) );
                    openInNewDoc = Convert.ToBoolean( xmlIn.GetAttribute( "newOnChange" ) );
                    rememberOnChange = Convert.ToBoolean( xmlIn.GetAttribute( "rememberOnChange" ) );

                    ret = true;
                }
                catch
                {
                }
                finally
                {
                    if ( xmlIn != null )
                        xmlIn.Close( );
                }
            }
            return ret;
        }
    }
}

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 GNU General Public License (GPLv3)

Share

About the Author

Andrew Kirillov
Software Developer (Senior) Cisco Systems
United Kingdom United Kingdom
Started software development at about 15 years old and it seems like now it lasts most part of my life. Fortunately did not spend too much time with Z80 and BK0010 and switched to 8086 and further. Similar with programming languages – luckily managed to get away from BASIC and Pascal to things like Assembler, C, C++ and then C#. Apart from daily programming for food, do it also for hobby, where mostly enjoy areas like Computer Vision, Robotics and AI. This led to some open source stuff like AForge.NET.
 
Going out of computers I am just a man loving his family, enjoying traveling, a bit of books, a bit of movies and a mixture of everything else. Always wanted to learn playing guitar, but it seems like 6 strings are much harder than few dozens of keyboard’s keys. Will keep progressing ...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141216.1 | Last Updated 13 Mar 2007
Article Copyright 2005 by Andrew Kirillov
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid