<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Crop Image &#8211; C# and VB.NET</title>
	<atom:link href="http://www.farooqazam.net/crop-image-c-sharp-and-vb-net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.farooqazam.net/crop-image-c-sharp-and-vb-net/</link>
	<description>Unity 3D, Game Development and C# Programming.</description>
	<lastBuildDate>Tue, 06 Dec 2011 13:14:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Mindy</title>
		<link>http://www.farooqazam.net/crop-image-c-sharp-and-vb-net/#comment-7557</link>
		<dc:creator>Mindy</dc:creator>
		<pubDate>Fri, 10 Dec 2010 15:38:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.farooqazam.net/?p=239#comment-7557</guid>
		<description>Hello, currently I&#039;m learning to program c# for image processing. I&#039;ve tried your source code but it seems to not working. Here&#039;s my code and please correct me. Thank you.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Bitmap CropImage(Bitmap source, Rectangle section)
        {
            Bitmap bmp = new Bitmap(section.Width, section.Height);

            Graphics g = Graphics.FromImage(bmp);

            g.DrawImage(source, 0, 0, section, GraphicsUnit.Pixel);

            return bmp;
        }

        public Form1()
        {
            InitializeComponent();
        }


        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string Chosen_File = &quot;&quot;;


            openFD.InitialDirectory = &quot;C:&quot;;
            openFD.Title = &quot;Insert Image&quot;;
            openFD.FileName = &quot;&quot;;
            openFD.Filter = &quot;JPEG Images&#124;*.jpg&#124;GIF Images&#124;*.gif&#124;BITMAPS&#124;*.bmp&#124;All Files&#124;*.*&quot;;

            if (openFD.ShowDialog() == DialogResult.Cancel)
            {
                MessageBox.Show(&quot;Cancel?&quot;);

            }
            else
            {

                Chosen_File = openFD.FileName;
                pictureBox1.Image = Image.FromFile(Chosen_File);
            }

        }

        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string Saved_File = &quot;&quot;;
            saveFileDialog.DefaultExt = &quot;jpg&quot;;
            saveFileDialog.Filter = &quot;JPEG Images&#124;*.jpg&#124;GIF Images&#124;*.gif&#124;BITMAPS&#124;*.bmp&#124;All Files&#124;*.*&quot;;
            saveFileDialog.AddExtension = true;
            saveFileDialog.RestoreDirectory = true;
            saveFileDialog.Title = &quot;Where do you want to save the file?&quot;;
            saveFileDialog.FileName = &quot;&quot;;
            saveFileDialog.InitialDirectory = &quot;C:\\&quot;;

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                Saved_File = saveFileDialog.FileName;
                MessageBox.Show(&quot;You selected the file: &quot; + Saved_File);
                try
                {
                    pictureBox1.Image.Save(Saved_File);
                }
                catch (Exception f)
                {
                    MessageBox.Show(f.Message);
                }
            }
            else
            {
                MessageBox.Show(&quot;Cancel or closed the dialog.&quot;);
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(&quot;Seriously quitting?? :(&quot;, &quot;Exit&quot;, MessageBoxButtons.OKCancel) == DialogResult.OK)

                Application.Exit();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;

        }

        private void cropToolStripMenuItem_Click(object sender, EventArgs e)
        {
             Bitmap img = new Bitmap(pictureBox1.Image);

            // The section that will be cropped.
            Rectangle section = new Rectangle(10, 10, 100, 100);

            // Crop the image and save it
            img = CropImage(img, section);
            img.Save(&quot;C:\\test.jpg&quot;);

        }
        }
    }</description>
		<content:encoded><![CDATA[<p>Hello, currently I&#8217;m learning to program c# for image processing. I&#8217;ve tried your source code but it seems to not working. Here&#8217;s my code and please correct me. Thank you.</p>
<p>using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Windows.Forms;</p>
<p>namespace WindowsFormsApplication1<br />
{<br />
    public partial class Form1 : Form<br />
    {<br />
        public Bitmap CropImage(Bitmap source, Rectangle section)<br />
        {<br />
            Bitmap bmp = new Bitmap(section.Width, section.Height);</p>
<p>            Graphics g = Graphics.FromImage(bmp);</p>
<p>            g.DrawImage(source, 0, 0, section, GraphicsUnit.Pixel);</p>
<p>            return bmp;<br />
        }</p>
<p>        public Form1()<br />
        {<br />
            InitializeComponent();<br />
        }</p>
<p>        private void openToolStripMenuItem_Click(object sender, EventArgs e)<br />
        {<br />
            string Chosen_File = &#8220;&#8221;;</p>
<p>            openFD.InitialDirectory = &#8220;C:&#8221;;<br />
            openFD.Title = &#8220;Insert Image&#8221;;<br />
            openFD.FileName = &#8220;&#8221;;<br />
            openFD.Filter = &#8220;JPEG Images|*.jpg|GIF Images|*.gif|BITMAPS|*.bmp|All Files|*.*&#8221;;</p>
<p>            if (openFD.ShowDialog() == DialogResult.Cancel)<br />
            {<br />
                MessageBox.Show(&#8220;Cancel?&#8221;);</p>
<p>            }<br />
            else<br />
            {</p>
<p>                Chosen_File = openFD.FileName;<br />
                pictureBox1.Image = Image.FromFile(Chosen_File);<br />
            }</p>
<p>        }</p>
<p>        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)<br />
        {<br />
            string Saved_File = &#8220;&#8221;;<br />
            saveFileDialog.DefaultExt = &#8220;jpg&#8221;;<br />
            saveFileDialog.Filter = &#8220;JPEG Images|*.jpg|GIF Images|*.gif|BITMAPS|*.bmp|All Files|*.*&#8221;;<br />
            saveFileDialog.AddExtension = true;<br />
            saveFileDialog.RestoreDirectory = true;<br />
            saveFileDialog.Title = &#8220;Where do you want to save the file?&#8221;;<br />
            saveFileDialog.FileName = &#8220;&#8221;;<br />
            saveFileDialog.InitialDirectory = &#8220;C:\\&#8221;;</p>
<p>            if (saveFileDialog.ShowDialog() == DialogResult.OK)<br />
            {<br />
                Saved_File = saveFileDialog.FileName;<br />
                MessageBox.Show(&#8220;You selected the file: &#8221; + Saved_File);<br />
                try<br />
                {<br />
                    pictureBox1.Image.Save(Saved_File);<br />
                }<br />
                catch (Exception f)<br />
                {<br />
                    MessageBox.Show(f.Message);<br />
                }<br />
            }<br />
            else<br />
            {<br />
                MessageBox.Show(&#8220;Cancel or closed the dialog.&#8221;);<br />
            }<br />
        }</p>
<p>        private void exitToolStripMenuItem_Click(object sender, EventArgs e)<br />
        {<br />
            if (MessageBox.Show(&#8220;Seriously quitting?? <img src='http://www.farooqazam.net/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> &#8220;, &#8220;Exit&#8221;, MessageBoxButtons.OKCancel) == DialogResult.OK)</p>
<p>                Application.Exit();<br />
        }</p>
<p>        private void pictureBox1_Click(object sender, EventArgs e)<br />
        {<br />
            pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;</p>
<p>        }</p>
<p>        private void cropToolStripMenuItem_Click(object sender, EventArgs e)<br />
        {<br />
             Bitmap img = new Bitmap(pictureBox1.Image);</p>
<p>            // The section that will be cropped.<br />
            Rectangle section = new Rectangle(10, 10, 100, 100);</p>
<p>            // Crop the image and save it<br />
            img = CropImage(img, section);<br />
            img.Save(&#8220;C:\\test.jpg&#8221;);</p>
<p>        }<br />
        }<br />
    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sebastian Jakins</title>
		<link>http://www.farooqazam.net/crop-image-c-sharp-and-vb-net/#comment-3426</link>
		<dc:creator>Sebastian Jakins</dc:creator>
		<pubDate>Wed, 08 Sep 2010 22:07:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.farooqazam.net/?p=239#comment-3426</guid>
		<description>This work perfectly.  I am definitely not a programmer but it makes sense and does exactly what I need it to do.</description>
		<content:encoded><![CDATA[<p>This work perfectly.  I am definitely not a programmer but it makes sense and does exactly what I need it to do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Farooq Azam</title>
		<link>http://www.farooqazam.net/crop-image-c-sharp-and-vb-net/#comment-1727</link>
		<dc:creator>Farooq Azam</dc:creator>
		<pubDate>Fri, 09 Jul 2010 13:46:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.farooqazam.net/?p=239#comment-1727</guid>
		<description>Sorry, I don&#039;t have Vs2005.

Download the source code. And make a new project in Vs2005 and copy the code from the &quot;.cs&quot; files.</description>
		<content:encoded><![CDATA[<p>Sorry, I don&#8217;t have Vs2005.</p>
<p>Download the source code. And make a new project in Vs2005 and copy the code from the &#8220;.cs&#8221; files.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niranjan Bestha</title>
		<link>http://www.farooqazam.net/crop-image-c-sharp-and-vb-net/#comment-1709</link>
		<dc:creator>Niranjan Bestha</dc:creator>
		<pubDate>Wed, 07 Jul 2010 05:28:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.farooqazam.net/?p=239#comment-1709</guid>
		<description>plz send crop image source code in visual studion 2005 version</description>
		<content:encoded><![CDATA[<p>plz send crop image source code in visual studion 2005 version</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Farooq Azam</title>
		<link>http://www.farooqazam.net/crop-image-c-sharp-and-vb-net/#comment-1537</link>
		<dc:creator>Farooq Azam</dc:creator>
		<pubDate>Sun, 20 Jun 2010 07:04:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.farooqazam.net/?p=239#comment-1537</guid>
		<description>I always assume the reader will have basic knowledge of C# / VB.NET. That is why I don&#039;t explain where to place the code because its pretty simple.

I&#039;ve edited the post. You can download the source code now.</description>
		<content:encoded><![CDATA[<p>I always assume the reader will have basic knowledge of C# / VB.NET. That is why I don&#8217;t explain where to place the code because its pretty simple.</p>
<p>I&#8217;ve edited the post. You can download the source code now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://www.farooqazam.net/crop-image-c-sharp-and-vb-net/#comment-1532</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Sat, 19 Jun 2010 17:49:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.farooqazam.net/?p=239#comment-1532</guid>
		<description>You need to explain where exactly people are supposed to place the code parts...you are just dropping code blindly and not telling us where to place the code...even better, just include the project file as a download...you can easily use MEGAUPLOAD or RAPIDSHARE....this saves people headaches.</description>
		<content:encoded><![CDATA[<p>You need to explain where exactly people are supposed to place the code parts&#8230;you are just dropping code blindly and not telling us where to place the code&#8230;even better, just include the project file as a download&#8230;you can easily use MEGAUPLOAD or RAPIDSHARE&#8230;.this saves people headaches.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mubarak</title>
		<link>http://www.farooqazam.net/crop-image-c-sharp-and-vb-net/#comment-1363</link>
		<dc:creator>Mubarak</dc:creator>
		<pubDate>Wed, 02 Jun 2010 09:18:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.farooqazam.net/?p=239#comment-1363</guid>
		<description>Great tutorial.... keep it up bro :)</description>
		<content:encoded><![CDATA[<p>Great tutorial&#8230;. keep it up bro <img src='http://www.farooqazam.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

