<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Reference Designer</title>
	<atom:link href="http://referencedesigner.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://referencedesigner.com/blog</link>
	<description>A Technology Blog</description>
	<lastBuildDate>Thu, 17 May 2012 17:53:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Understanding Timers in MSP430 #3</title>
		<link>http://referencedesigner.com/blog/understanding-timers-in-msp430-3/2068/</link>
		<comments>http://referencedesigner.com/blog/understanding-timers-in-msp430-3/2068/#comments</comments>
		<pubDate>Thu, 17 May 2012 16:03:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://referencedesigner.com/blog/?p=2068</guid>
		<description><![CDATA[We now define an interrupt vector. When a timer interrupt occurs, it runs the code defined in the interrupt routine. Take a look at the Interrupt routine. #include &#60;msp430x14x.h&#62; void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P6DIR &#124;= 0x08; // P6.3 Set P6.3 to output CCTL0 = CCIE; // CCR0 interrupt [...]]]></description>
			<content:encoded><![CDATA[<p>We now define an interrupt vector. When a timer interrupt occurs, it runs the code defined in the interrupt routine. Take a look at the Interrupt routine.</p>
<p>#include &lt;msp430x14x.h&gt;<br />
<code><br />
void main(void)<br />
{<br />
WDTCTL = WDTPW + WDTHOLD; // Stop WDT<br />
P6DIR |= 0x08; // P6.3 Set P6.3 to output<br />
CCTL0 = CCIE; // CCR0 interrupt enabled<br />
CCR0 = 60000;<br />
TACTL = TASSEL_2 + MC_2; // SMCLK, contmode<br />
_BIS_SR(GIE); // Enable interrupt<br />
}</code></p>
<p>// Timer A0 interrupt service routine<br />
<span style="color: #ff0000;">#pragma vector=TIMERA0_VECTOR</span><br />
<span style="color: #ff0000;"> __interrupt void Timer_A (void)</span><br />
<span style="color: #ff0000;"> {</span><br />
<span style="color: #ff0000;"> P6OUT ^= 0&#215;08; // Toggle P6.3</span><br />
<span style="color: #ff0000;"> CCR0 += 60000; // Add Offset to CCR0</span><br />
<span style="color: #ff0000;"> }</span></p>
<p>If you run this code you and observe the signal, you get a screen shot something similar to</p>
<p><a href="http://referencedesigner.com/blog/wp-content/uploads/2012/05/timer1.png"><img class="aligncenter size-full wp-image-2069" title="timer1" src="http://referencedesigner.com/blog/wp-content/uploads/2012/05/timer1.png" alt="" width="672" height="299" /></a></p>
<p><strong>Some Experiments </strong></p>
<p>Here are some experiments you can do.</p>
<p>1. Try changing </p>
<p> CCR0 += 60000;</p>
<p>to</p>
<p>CCR0 += 30000; </p>
<p>and you will observe that time period becomes half. Changing it to CCR0 += 6000; will reduce it to 1/10th.</p>
<p>2. If you want a slower timer, you may change the </p>
<p>TACTL = TASSEL_2 + MC_2;</p>
<p>to</p>
<p>TACTL = TASSEL_1 + MC_2;</p>
<p>Which will change the clock from SMCLK ( derived from 4 MHz) to ACLK ( derived from 32.768 KHz).<br />
3. If you change </p>
<p>TACTL = TASSEL_2 + MC_2 ;</p>
<p>to</p>
<p>TACTL = TASSEL_2 + MC_2 + ID_1; </p>
<p>it doubles the time period ( by by halving the clock period used for timer interrupt). Bit 7-6 defines it.</p>
<p>IDx Bits</p>
<p>00  divide by 1<br />
01  divide by 2<br />
10  divide by 4<br />
11  divide by 8 </p>
]]></content:encoded>
			<wfw:commentRss>http://referencedesigner.com/blog/understanding-timers-in-msp430-3/2068/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding Timers in MS430 #2</title>
		<link>http://referencedesigner.com/blog/understanding-timers-in-ms430-2/2062/</link>
		<comments>http://referencedesigner.com/blog/understanding-timers-in-ms430-2/2062/#comments</comments>
		<pubDate>Thu, 17 May 2012 15:35:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://referencedesigner.com/blog/?p=2062</guid>
		<description><![CDATA[Add three more lines in the main programs ( highlighted in red). void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop WDT P6DIR &#124;= 0x08; // P6.3 Set P6.3 to output CCTL0 = CCIE; // CCR0 interrupt enabled CCR0 = 60000; TACTL = TASSEL_2 + MC_2; // SMCLK, contmode _BIS_SR(GIE); // Enable interrupt } [...]]]></description>
			<content:encoded><![CDATA[<p>Add three more lines in the main programs ( highlighted in red).</p>
<p><code>void main(void)<br />
{<br />
WDTCTL = WDTPW + WDTHOLD; // Stop WDT<br />
P6DIR |= 0x08; // P6.3 Set P6.3 to output<br />
<span style="color: #ff0000;">CCTL0 = CCIE; // CCR0 interrupt enabled</span><br />
<span style="color: #ff0000;"> CCR0 = 60000;</span><br />
<span style="color: #ff0000;"> TACTL = TASSEL_2 + MC_2; // SMCLK, contmode</span><br />
<span style="color: #ff0000;"> _BIS_SR(GIE); // Enable interrupt</span><br />
}</code></p>
<p>Let is now try to understand the code one by one..</p>
<p><strong>CCTL0 Register</strong></p>
<p>If you plan to use a Timer, the first register that you need to set is CCTL0. It is a 16 bit register and settings of this register effects how we use the register. For our purpose we just tell it to enable the interrupt using </p>
<p><strong>CCTL0 = CCIE;</strong></p>
<p>Notice that we have not yet enabled the timer. </p>
<p><strong>CCR0</strong></p>
<p>This register will define the amount of time after which the timer event will occur. We have set it to </p>
<p>CCR0 = 60000;</p>
<p><strong> TACTL</strong></p>
<p>Bit 9-8 selects the source of the clock</p>
<p>The Possible values are </p>
<p>00 TACLK<br />
01 ACLK<br />
10 SMCLK<br />
11 INCLK</p>
<p>We have basically selected the SMCLK which is a 4 MHz clock in our case.</p>
<p>The bits 5-4 selects how the counting. Possible values are </p>
<p>00 Stop mode: the timer is halted<br />
01 Up mode: the timer counts up to TACCR0<br />
10 Continuous mode: the timer counts up to 0FFFFh<br />
11 Up/down mode: the timer counts up to TACCR0 then down to 0000h</p>
<p>We have selected 10 which makes the counter count upto 0FFFFh</p>
<p><strong>Enable General Interrupt</strong></p>
<p>Finally we have to enable the general interrupt using.</p>
<p>_BIS_SR(GIE);</p>
<p>This statements sets the GIE bit in the Status register which enables the interrupt. Notice that we have not yet defined the interrupt vector. We will do it in the next page. The code as of now will compile but will not produce any observable result.</p>
<p><a href="http://referencedesigner.com/blog/understanding-timers-in-msp430-3/2068/"><img src="http://referencedesigner.com/blog/wp-content/uploads/2012/05/Next3.jpg" alt="" title="Next3" width="135" height="94" class="alignright size-full wp-image-2077" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://referencedesigner.com/blog/understanding-timers-in-ms430-2/2062/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding Timers in MSP430</title>
		<link>http://referencedesigner.com/blog/understanding-timers-in-msp430/2060/</link>
		<comments>http://referencedesigner.com/blog/understanding-timers-in-msp430/2060/#comments</comments>
		<pubDate>Thu, 17 May 2012 15:31:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://referencedesigner.com/blog/?p=2060</guid>
		<description><![CDATA[We will understand the concept of timer by writing an actual software. The purpose of the program is to generate well defined pulse(s) of alternate high and low. This is something simple, but the key here is to understand the Timer concept rather than generating the square pulse. You will need an oscilloscope to capture [...]]]></description>
			<content:encoded><![CDATA[<p>We will understand the concept of timer by writing an actual software. The purpose of the program is to generate well defined pulse(s) of alternate high and low. This is something simple, but the key here is to understand the Timer concept rather than generating the square pulse. You will need an oscilloscope to capture the high low sequence.   </p>
<p><strong>Preparing your hardware</strong></p>
<p>Before we start our experiment, let us make sure that our hardware is in place. We do this by writing the following code and checking that we are getting high ( or low ) at an IO port of the board we are testing. In out case it is P6.3, but you can use any other port. </p>
<p>Use the following code and make sure that the P6.3 ( or your chosen port) turns high and low before you start experimenting.</p>
<p><code>#include "msp430x14x.h"</p>
<p>void main(void)<br />
{<br />
WDTCTL = WDTPW + WDTHOLD; // Stop WDT<br />
P6DIR |= 0x08; // P6.3 Set P6.3 to output<br />
P6OUT &#038;= ~0x08; // P6.4  is low<br />
//P6OUT |= 0x08; // Use this if you want to check for high output.<br />
}</code></p>
<p>In the next page we will write the actual code that will run timer. </p>
<p><a href="http://referencedesigner.com/blog/understanding-timers-in-ms430-2/2062/"><img src="http://referencedesigner.com/blog/wp-content/uploads/2012/05/Next3.jpg" alt="" title="Next3" width="135" height="94" class="alignright size-full wp-image-2077" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://referencedesigner.com/blog/understanding-timers-in-msp430/2060/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to display html code on web page</title>
		<link>http://referencedesigner.com/blog/how-to-display-html-code-on-web-page/2057/</link>
		<comments>http://referencedesigner.com/blog/how-to-display-html-code-on-web-page/2057/#comments</comments>
		<pubDate>Sun, 08 Apr 2012 13:55:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://referencedesigner.com/blog/?p=2057</guid>
		<description><![CDATA[Let us assume you want to show a specific content of a webpage that shows an example html code. How do you do that ? If you write the content as it is, it just applies the markup and the html codes itself are not displayed. There is one solution. Use a tool from accessify. [...]]]></description>
			<content:encoded><![CDATA[<p>Let us assume you want to show a specific content of a webpage that shows an example html code. How do you do that ?<br />
If you write the content as it is, it just applies the markup and the html codes itself are not displayed. </p>
<p>There is one solution. Use a <a href="http://accessify.com/tools-and-wizards/developer-tools/quick-escape/default.php">tool from accessify</a>. </p>
<p>All you have to do is copy the content of the html that you wish to display in the tool&#8217;s text area and click convert to Escape characters. It renders the escaped character into that you can use. </p>
]]></content:encoded>
			<wfw:commentRss>http://referencedesigner.com/blog/how-to-display-html-code-on-web-page/2057/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Netlist with cadence 16.3 / Allegro in  windows 7 &#8211; Error initializing COM property pages</title>
		<link>http://referencedesigner.com/blog/netlist-with-cadence-16-3-allegro-in-windows-7-error-initializing-com-property-pages/2054/</link>
		<comments>http://referencedesigner.com/blog/netlist-with-cadence-16-3-allegro-in-windows-7-error-initializing-com-property-pages/2054/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 13:48:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://referencedesigner.com/blog/?p=2054</guid>
		<description><![CDATA[Did you get an error trying to generate a netlist from Cadence 16.3 Orcad for the Allegro PCB Editor 16.3. In some enterprise edition you get an error that pops up saying Error initializing COM property pages and says some &#8220;wrong pointer&#8221; etc. Here is a quick solution for it. Take a look at the [...]]]></description>
			<content:encoded><![CDATA[<p>Did you get an error trying to generate a netlist from Cadence 16.3 Orcad for the Allegro PCB Editor 16.3. In some enterprise edition you get an error that pops up saying </p>
<p>Error initializing COM property pages</p>
<p>and says some &#8220;wrong pointer&#8221; etc.</p>
<p>Here is a quick solution  for it. Take a look at the screen shot</p>
<p><a href="http://referencedesigner.com/blog/wp-content/uploads/2012/03/orcard_issue.png"><img src="http://referencedesigner.com/blog/wp-content/uploads/2012/03/orcard_issue.png" alt="" title="orcard_issue" width="404" height="267" class="aligncenter size-full wp-image-2055" /></a></p>
<p>Basically, you need to run the Orcad as an Administrator.  You need to do it only the first time. </p>
<p>Go </p>
]]></content:encoded>
			<wfw:commentRss>http://referencedesigner.com/blog/netlist-with-cadence-16-3-allegro-in-windows-7-error-initializing-com-property-pages/2054/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Watts Hour and Ampere Hour</title>
		<link>http://referencedesigner.com/blog/watts-hour-and-ampere-hour/2050/</link>
		<comments>http://referencedesigner.com/blog/watts-hour-and-ampere-hour/2050/#comments</comments>
		<pubDate>Sat, 10 Mar 2012 18:41:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://referencedesigner.com/blog/?p=2050</guid>
		<description><![CDATA[The capacity of a battery life is specified either in Ampere Hour or in Watts Hour. Let us understand the two terms and the inter relation between them. The Ampere Hour is more intuitive term for expressing the battery life. If a battery is specified at 20 Ampere hour then the implication is simple &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>The capacity of a battery life is specified either in Ampere Hour or in Watts Hour. Let us understand the two terms and the inter relation between them.</p>
<p>The Ampere Hour is more intuitive term for expressing the battery life. If a battery is specified at 20 Ampere hour then the implication is simple &#8211; A 20 Ampere hour battery life will last for 20 hours if it draws 1 Ampere of current. It will last for 10 hours if it draws 2 Ampere of current. Simple ?</p>
<p>The problem with the Ampere hour specification is that it does not specify the Voltage at the battery. Let us say you have two batteries. Both the batteries A and B has a Ampere Hour rating of 10 Ampere Hour. However, Battery A is at 3.6 Volts while the Battery B is at 7.2 Volts. Now if you draw 1 Ampere of current from both the batteries, both will last 10 hours. But the Battery B is delivering 1 Ampere at 7.2 Volts while the battery A is delivering it at only 3.6 Volts. I strictly technical terms we say that battery B has double the capacity of the battery A. </p>
<p>This is where the Watt hours come in play. If a battery is rated 20 Watt hours, it will mean that it will last for 20 hours if 1 Watt power is drawn from it. Now watt is defined at the product of the Volt ( at the battery) and Ampere ( drawn from the battery). </p>
<p>In the previous example, the 20 Ampere Hour 7.2 Volt battery would be rated as 1440 Watt Hour while the 20 Ampere Hour 3.6 Volt battery would be rated at 720 Watt Hour. </p>
<p>You can use the battery life calculator to <a href="http://www.referencedesigner.com/cal/cal_54.php">calculate the life of a battery</a>.  This calculator just calculates the battery life if you know the Ampere Hour rating and the current drawn from the battery.  </p>
]]></content:encoded>
			<wfw:commentRss>http://referencedesigner.com/blog/watts-hour-and-ampere-hour/2050/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RMS Formula ( Root Mean Square Formula)</title>
		<link>http://referencedesigner.com/blog/rms-formula-root-mean-square-formula/2042/</link>
		<comments>http://referencedesigner.com/blog/rms-formula-root-mean-square-formula/2042/#comments</comments>
		<pubDate>Sat, 03 Mar 2012 00:24:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://referencedesigner.com/blog/?p=2042</guid>
		<description><![CDATA[The rms value of a set of n values for (x1, x2, &#8230;..xn) is given by This formula is valid for a set of n discrete values. If you have a continuous variable, you can use Calculus to derive the formula for various common waveforms, for example the sinusoidal waveform. For example if a is [...]]]></description>
			<content:encoded><![CDATA[<p>The rms value of a set of n values for (x1, x2, &#8230;..xn) is given by</p>
<p><img alt="" src="http://upload.wikimedia.org/wikipedia/en/math/1/3/f/13ff7a17de460cd4c28938d9fd08e730.png" class="alignnone" width="293" height="48" /></p>
<p>This formula is valid for a set of n discrete values. If you have a continuous variable, you can use Calculus to derive the formula for various common waveforms, for example the sinusoidal waveform.  </p>
<p>For example if a is the amplitude of a sinusoidal waveform the vrms is given by</p>
<p><img alt="" src="http://upload.wikimedia.org/wikipedia/en/math/4/b/0/4b01f1337e73a7a5db2c54d8ec6b69fa.png" class="alignnone" width="27" height="42" /></p>
<p><a href="http://referencedesigner.com/blog/wp-content/uploads/2012/03/400px-Waveforms.svg_.png"><img src="http://referencedesigner.com/blog/wp-content/uploads/2012/03/400px-Waveforms.svg_.png" alt="" title="400px-Waveforms.svg" width="400" height="83" class="aligncenter size-full wp-image-2048" /></a></p>
<p>You can use the following calculator to calculate the rms value , if you know the peak to peak value</p>
<p><a href="http://www.referencedesigner.com/rfcal/vrms-to-vpeak-conversion.php">rms to peak to peak calculator </a></p>
<p>Probably you cam here searching for the formula for the Root Mean Square or, rms for the short. Before we  give out the formula and the explanation, let us find the need of a root mean square.</p>
<p>A company Xing Hua, makes nuts and bolts and supplies it to various companies in US and Europe. The company makes a strict record of all the quality procedure that it adapts. </p>
<p>The nuts and bolts had their dimensions measured with automatic tools after they are finished and recorded in a spread sheet. That is a great !!! Said the CEO when he visited the shop and looked into the quality procedure adopted by them. The QA engineer then calculated the mean of the internal diameter of the nuts and found that the average of the dimension of is very close to the required dimension.  The required dimension was 2.050 mm while their average dimension was 2.051 mm. Pretty close.</p>
<p>A few months later the order that came from Japan for an automobile company was rejected. The company went bankrupt. </p>
<p>Explanation </p>
<p>Had the QA engineer measured the rms average in place or regular average, they could have caught the fault much earlier saving the company from bankruptcy.</p>
<p>You may have now understood the story now. Let us say we want to hit an average dia of 2.50 mm. If one piece has dia of 1.5 mm and second one has a dia of 3.5 mm, the average is still 2.50 mm, but both are useless.</p>
<p>So we define root mean square. </p>
<p>We take the difference. The differences are as follows</p>
<p>For 1.0 mm the difference is +1.0 mm<br />
For 1.5 mm the difference in -1.0 mm</p>
<p>The average is 0<br />
But the root mean square  is sqrt ( (1)^2 + (-1)^2) /2) = 1.0</p>
<p>This is 1.0 mm &#8211; non trivial value. </p>
<p>So coming back to the rms formula. Here is the formula for the RMS</p>
<p>The rms value of a set of n values for (x1, x2, &#8230;..xn) is given by</p>
<p><img alt="" src="http://upload.wikimedia.org/wikipedia/en/math/1/3/f/13ff7a17de460cd4c28938d9fd08e730.png" class="alignnone" width="293" height="48" /></p>
<p>Other Resources</p>
<p>- If you are, however looking at the rms value corresponding to a waveform, you may like to check <a href="http://www.referencedesigner.com/rfcal/vrms-to-vpeak-conversion.php">vrms to vpeak to peek calculator<br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://referencedesigner.com/blog/rms-formula-root-mean-square-formula/2042/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Photo Resizer program &#8211; Csharp Tutorial</title>
		<link>http://referencedesigner.com/blog/photo-resizer-program-csharp-tutorial/2036/</link>
		<comments>http://referencedesigner.com/blog/photo-resizer-program-csharp-tutorial/2036/#comments</comments>
		<pubDate>Sat, 18 Feb 2012 02:48:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://referencedesigner.com/blog/?p=2036</guid>
		<description><![CDATA[Basic Problem &#8211; Recent advent of high megapixel has created one problem &#8211; large image sizes. Today the Camera&#8217;s come at 15 Megapixels and higher. There are few issues with large size pictures 1. It takes longer to upload to facebook because of the size. 2. It is impractical to send large size image using [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Basic Problem</strong> &#8211; Recent advent of high megapixel has created one problem &#8211; large image sizes. Today the Camera&#8217;s come at 15 Megapixels and higher. There are few issues with large size pictures</p>
<p>1. It takes longer to upload to facebook because of the size.<br />
2. It is impractical to send large size image using email.<br />
3. Viewing large size creates issues when viewing it in some photo viewer.</p>
<p>When you transfer the photos from your camera to your computer, it gets stored in a directory. We wish to write a simple program that will create a new directory and will put all the resized images in the new directory.</p>
<p>Here is goes.</p>
<p><code>using System;<br />
using System.IO;<br />
using System.Drawing;<br />
using System.Drawing.Imaging;<br />
using System.Drawing.Drawing2D;</p>
<p>namespace Tutorial<br />
{<br />
    class ImageResize<br />
    {<br />
        enum Dimensions<br />
        {<br />
            Width,<br />
            Height<br />
        }</p>
<p>        [STAThread]<br />
        static void Main(string[] args)<br />
        {<br />
            //set a working directory<br />
            string WorkingDirectory = @"C:\Users\abhinsv\Desktop\Imageresize_src";</p>
<p>        string[] array1 = Directory.GetFiles(WorkingDirectory,"*.jpg");</p>
<p>        Console.WriteLine("Enter the percentage you wish to compress");<br />
        int pc = Convert.ToInt32 (Console.ReadLine());</p>
<p>        System.IO.Directory.CreateDirectory(WorkingDirectory + @"\images" + pc.ToString() + @"\");</p>
<p>            foreach (string name in array1)</p>
<p>        {</p>
<p>            Image imgPhotoVert = Image.FromFile(name);<br />
            Image imgPhoto = null;</p>
<p>            imgPhoto = ScaleByPercent(imgPhotoVert, pc);<br />
            imgPhoto.Save(WorkingDirectory + @"\images"+ pc.ToString()+ @"\" + Path.GetFileName(name), ImageFormat.Jpeg);<br />
            imgPhoto.Dispose();</p>
<p>        }</p>
<p>        }<br />
        static Image ScaleByPercent(Image imgPhoto, int Percent)<br />
        {<br />
            float nPercent = ((float)Percent / 100);</p>
<p>            int sourceWidth = imgPhoto.Width;<br />
            int sourceHeight = imgPhoto.Height;<br />
            int sourceX = 0;<br />
            int sourceY = 0;</p>
<p>            int destX = 0;<br />
            int destY = 0;<br />
            int destWidth = (int)(sourceWidth * nPercent);<br />
            int destHeight = (int)(sourceHeight * nPercent);</p>
<p>            Bitmap bmPhoto = new Bitmap(destWidth, destHeight, PixelFormat.Format24bppRgb);<br />
            bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);</p>
<p>            Graphics grPhoto = Graphics.FromImage(bmPhoto);<br />
            grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;</p>
<p>            grPhoto.DrawImage(imgPhoto,<br />
                new Rectangle(destX, destY, destWidth, destHeight),<br />
                new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),<br />
                GraphicsUnit.Pixel);</p>
<p>            grPhoto.Dispose();<br />
            return bmPhoto;<br />
        }</p>
<p>          }</p>
<p>}<br />
    </code>    </p>
<p>If you are uninitiated, you may like to take <a href="http://referencedesigner.com/tutorials/csharp/csharp_1.php">CSharp Tutorial</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://referencedesigner.com/blog/photo-resizer-program-csharp-tutorial/2036/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to find list of files in a directory in Csharp &#8211; A tutorial</title>
		<link>http://referencedesigner.com/blog/how-to-find-list-of-files-in-a-directory-in-csharp-a-tutorial/2029/</link>
		<comments>http://referencedesigner.com/blog/how-to-find-list-of-files-in-a-directory-in-csharp-a-tutorial/2029/#comments</comments>
		<pubDate>Sat, 18 Feb 2012 02:05:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://referencedesigner.com/blog/?p=2029</guid>
		<description><![CDATA[In many cases you need to read the file names in a directory to be able to process or take some action to process the files. Here is a simple program that will list out the files in a directory. using System; using System.IO; class Program { static void Main() { // Put all file [...]]]></description>
			<content:encoded><![CDATA[<p>In many cases you need to read the file names in a directory to be able to process or take some action to process the files. Here is a simple program that will list out the files in a directory.</p>
<p><code>using System;<br />
using System.IO;</p>
<p>class Program<br />
{<br />
    static void Main()<br />
    {<br />
        // Put all file names in root directory into array.<br />
        string WorkingDirectory = @"C:\Users\abhinsv\Desktop\Imageresize_src\";<br />
        string[] array1 = Directory.GetFiles(WorkingDirectory,"*.jpg");</p>
<p>         Console.WriteLine("--- List of the Files: ---");<br />
        foreach (string name in array1)<br />
        {<br />
            Console.WriteLine(name);</p>
<p>        }</p>
<p>        Console.ReadLine();</p>
<p>    }<br />
}<br />
</code></p>
<p>Pay special attention to </p>
<p>Directory.GetFiles(WorkingDirectory,&#8221;*.jpg&#8221;);</p>
<p>It will list out all the files in the directory with the extension jpg. If you wish to list all files, irrespective of the extension, you may use </p>
<p>Directory.GetFiles(WorkingDirectory);</p>
<p>It will list all files with in the directory WITH path. Here is a typical output</p>
<p><code>--- List of the Files: ---<br />
C:\Users\abhinsv\Desktop\Imageresize_src\imageresize_horiz.jpg<br />
C:\Users\abhinsv\Desktop\Imageresize_src\imageresize_vert.jpg</p>
<p></code><br />
If you want to list only the names of the file, you can use</p>
<p><code>Console.WriteLine(Path.GetFileName(name));</code></p>
<p>in place of </p>
<p><code>Console.WriteLine(name);</code></p>
<p>This will, for example give the following output<br />
<code><br />
--- List of the Files: ---<br />
imageresize_horiz.jpg<br />
imageresize_vert.jpg</code></p>
<p>If you are uninitiated, you may like to take <a href="http://referencedesigner.com/tutorials/csharp/csharp_1.php">CSharp Tutorial</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://referencedesigner.com/blog/how-to-find-list-of-files-in-a-directory-in-csharp-a-tutorial/2029/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a new directory &#8211; Csharp Tutorial</title>
		<link>http://referencedesigner.com/blog/create-a-new-directory-csharp-tutorial/2027/</link>
		<comments>http://referencedesigner.com/blog/create-a-new-directory-csharp-tutorial/2027/#comments</comments>
		<pubDate>Sat, 18 Feb 2012 02:01:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://referencedesigner.com/blog/?p=2027</guid>
		<description><![CDATA[Creating a new directory is very simple using Csharp.  The following statement will create a new directory placed in the path C:\directory\subdirectory\. If the directory already exists with files in it, it will not be deleted and the files will not be removed. System.IO.Directory.CreateDirectory("C:\directory\subdirectory\newdirectory); using System; namespace Tutorial { class CreateDirectory { static void Main(string[] [...]]]></description>
			<content:encoded><![CDATA[<p>Creating a new directory is very simple using Csharp.  The following statement will create a new directory placed in the path C:\directory\subdirectory\. If the directory already exists with files in it, it will not be deleted and the files will not be removed. </p>
<p><code>System.IO.Directory.CreateDirectory("C:\directory\subdirectory\newdirectory);</code></p>
<p>using System;</p>
<p>namespace Tutorial<br />
{<br />
      class CreateDirectory<br />
    {<br />
          static void Main(string[] args)<br />
          {<br />
              //set a working directory<br />
              string WorkingDirectory = @&#8221;C:\Users\abhinsv\Desktop\Imageresize_src&#8221;;<br />
              System.IO.Directory.CreateDirectory(WorkingDirectory + @&#8221;\images&#8221;);<br />
          }</p>
<p>     }<br />
}</p>
<p>If you are uninitiated in C Sharp, you may like to check <a href="http://referencedesigner.com/tutorials/csharp/csharp_1.php">CSharp Tutorial for beginners</a>.</p>
<p>Here is the complete code to do this.</p>
]]></content:encoded>
			<wfw:commentRss>http://referencedesigner.com/blog/create-a-new-directory-csharp-tutorial/2027/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

