<?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>Toni Westbrook dot Com &#187; Web</title>
	<atom:link href="http://www.toniwestbrook.com/archives/category/web/feed" rel="self" type="application/rss+xml" />
	<link>http://www.toniwestbrook.com</link>
	<description>Sharing Software Development Knowledge With You</description>
	<lastBuildDate>Mon, 12 Sep 2011 03:35:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Spotlight: Leah Creates</title>
		<link>http://www.toniwestbrook.com/archives/439</link>
		<comments>http://www.toniwestbrook.com/archives/439#comments</comments>
		<pubDate>Sun, 30 Jan 2011 01:43:08 +0000</pubDate>
		<dc:creator>Toni</dc:creator>
				<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.toniwestbrook.com/?p=439</guid>
		<description><![CDATA[One of the best things about being involved in the world of technology, besides getting a front row seat to all the amazing advancements made every day, is meeting and talking with the creative people who make the magic happen. I think I&#8217;m especially lucky, having strong ties to a range of different areas such [...]]]></description>
			<content:encoded><![CDATA[<p>One of the best things about being involved in the world of technology, besides getting a front row seat to all the amazing advancements made every day, is meeting and talking with the creative people who make the magic happen.  I think I&#8217;m especially lucky, having strong ties to a range of different areas such as networking and development, to have met a diverse mix of very talented people.  </p>
<p><b>Web Developer Extraordinaire</b></p>
<p><img src="http://www.toniwestbrook.com/wp-content/uploads/2011/01/leah.jpg" alt="" title="LeahCreates" align=right valign=top style="margin-left:5px" />To say business exists in a social media world where online presence and reputation is important would be the understatement of the century.  Companies today live and die by their ability to harness the power of the web.  And while there are many developers out there, a true burden lies in finding talented and experienced ones.  Not only does Leah fall into this camp, combining expert design skill with seasoned web development knowledge, but she possesses something that many in the industry don&#8217;t – a real love and respect for what her customers are trying to accomplish with their website.  This truly shines through both in her work, and how she treats her clients.  It translates into a special website that speaks its goals and connects to its visitors like no other site could.  It is the difference between a good looking site and a truly powerful site.  </p>
<p><b>The Proof is in the Pudding</b></p>
<p>I&#8217;ve known Leah for a number of years, having had the privilege of working with her on a number of projects professionally – and her sites continue to really impress me.  Some excellent examples of recent projects: <a href="http://www.beirreplaceable.com">Be Irreplaceable</a> | <a href="http://www.donnaheart.com/">Donna Heart</a>.</p>
<p><center><img src="http://www.toniwestbrook.com/wp-content/uploads/2011/01/donna.jpg" alt="" title="DonnaHeart" style="margin-bottom:10px" /></center></p>
<p>I love these examples, as they show how she has taken a general framework like WordPress, and turned it into a beautiful site that really communicates the site&#8217;s message.  They feel personable and comfortable when you visit them, unlike a lot of cold and bland sites out there.  They have that truly personal touch which is key to connecting with the audience.</p>
<p>For even more examples of her work, check out her <a href="http://www.leahcreates.com/portfolio">online portfolio</a>.</p>
<p>So if you&#8217;re looking to build a new website for your business, or need to re-imagine the one you already have, I really suggest keeping Leah Creates in mind.  She is amazing at both what she does, and how she does it – something setting her apart from so many other development houses out there.</p>
<p><a href="http://www.leahcreates.com">LeahCreates</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.toniwestbrook.com/archives/439/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a PHP Graphing Calculator</title>
		<link>http://www.toniwestbrook.com/archives/68</link>
		<comments>http://www.toniwestbrook.com/archives/68#comments</comments>
		<pubDate>Thu, 10 Apr 2008 00:34:55 +0000</pubDate>
		<dc:creator>Toni</dc:creator>
				<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.toniwestbrook.com/archives/68</guid>
		<description><![CDATA[When I want to learn a new technology or technique, I like to think about little projects I&#8217;ve always wanted to try, and see if the project could be implemented using the new technology. In this case, I&#8217;ve worked quite a bit with .NET&#8217;s image and graphic related classes and methods, but had never really [...]]]></description>
			<content:encoded><![CDATA[<p>When I want to learn a new technology or technique, I like to think about little projects I&#8217;ve always wanted to try, and see if the project could be implemented using the new technology.</p>
<p>In this case, I&#8217;ve worked quite a bit with .NET&#8217;s image and graphic related classes and methods, but had never really investigated the PHP equivalent.  After reading up on PHP&#8217;s GD library, I decided to give writing a simple graphing calculator a go.  </p>
<p>This tutorial will get you started and allow your users to enter in equations to generate graphs like this:</p>
<p><img src="http://www.toniwestbrook.com/images/posts/graph1.jpg" alt="Graph 1" /></p>
<p><img src="http://www.toniwestbrook.com/images/posts/graph2.jpg" alt="Graph 2" /> </p>
<p>It will also let users use standard PHP functions and code, giving them use of the full math library, modulus, random functions, etc.  You can do some really neat things like this:</p>
<p><img src="http://www.toniwestbrook.com/images/posts/graph3.jpg" alt="Graph 3" /> </p>
<p>So let&#8217;s get started.  In this example, the webpage has a single text box that takes an equation, submits back to the page, and the PHP writes an image directly to the browser.  Please note, this example doesn&#8217;t do any error checking or sanitation of input &#8211; please include it in your final code, especially since this page makes use of the &#8220;eval&#8221; function which is a huge security risk.</p>
<div style="font-size:10px">
<pre class="brush: php">

&lt; ? php
if ($_POST[&#039;tempBox&#039;] != &#039;&#039;)
{
   // width, height, and scale of graph.  These could also be user defined values.
   $GLOBALS[&#039;width&#039;] = 500;
   $GLOBALS[&#039;height&#039;] = 500;
   $GLOBALS[&#039;scale&#039;] = 1;

   // drawGrid draws X and Y axis with markers every 50 points
   // We pass in the image resource to draw to
   function drawGrid($passGraphic)
   {
      // Grid is grey
      $gridColor = imagecolorallocate($passGraphic, 200, 200, 200);

      // Draw two lines, one vertical in the middle of the grid (width/2)
      // and another horizontal in the middle of the grid (height/2)
      imageline($passGraphic, $GLOBALS[&#039;width&#039;]/2, 0, $GLOBALS[&#039;width&#039;]/2, $GLOBALS[&#039;height&#039;], $gridColor);
      imageline($passGraphic, 0, $GLOBALS[&#039;height&#039;]/2, $GLOBALS[&#039;width&#039;], $GLOBALS[&#039;height&#039;]/2, $gridColor);

      // Draw a marker ever 50 points on the X axis.  We do this by starting at the center
      // of the board, then incrementing 50 with every iteration.  We also
      // draw a mark in the mirror location to cover the negative side of the axis
      for ($lcv = 0 ; $lcv &lt; $GLOBALS[&#039;width&#039;] / 2 / $GLOBALS[&#039;scale&#039;]; $lcv += 50)
      {
           // Set tempX and tempY to the current marker location
           $tempX = $lcv;
           $tempY = 0;

           // Convert to image coordinates
           cartToPixels($tempX, $tempY);

           // Draw the line
           imageline($passGraphic, $tempX, $tempY - 10, $tempX, $tempY + 10, $gridColor); 

           // Now do the same for the negative side of the axis
           $tempX = $lcv * -1;
           $tempY = 0;
           cartToPixels($tempX, $tempY);
           imageline($passGraphic, $tempX, $tempY - 10, $tempX, $tempY + 10, $gridColor);
      } 

      // We use the same method for drawing markers on the Y axis.
      for ($lcv = 0 ; $lcv &lt; $GLOBALS[&#039;height&#039;] / 2 / $GLOBALS[&#039;scale&#039;] ; $lcv += 50)
      {
           $tempX = 0;
           $tempY = $lcv;
           cartToPixels($tempX, $tempY);
           imageline($passGraphic, $tempX - 10, $tempY, $tempX + 10, $tempY, $gridColor);
           $tempX = 0;
           $tempY = $lcv * -1;
           cartToPixels($tempX, $tempY);
           imageline($passGraphic, $tempX - 10, $tempY, $tempX + 10, $tempY, $gridColor);
      } 

   }

   // cartToPixels converts Cartesian coordinates to image coordinates, using the SCALE variable to
   // do a zoom conversion between the two.
   // The two gotchas are, coordinates start from the center, and the Y axis goes in the
   // opposite direction (image coordinates, increase in Y goes down.  Cartesian, increase
   // in Y goes up).
   function cartToPixels(&amp;$passX, &amp;$passY)
   {
      // Start from the middle, otherwise 1 to 1 for X
      $passX = $GLOBALS[&#039;width&#039;] / 2 + $passX * $GLOBALS[&#039;scale&#039;];

      // Start from the middle, also subtract to flip for Y
      $passY = $GLOBALS[&#039;height&#039;] / 2 - $passY * $GLOBALS[&#039;scale&#039;];

   }

   // pixelsToCart converts from image coordinates to
   // Cartesian coordinates.  Uses the same process as
   // above but reversed.
   function pixelsToCart(&amp;$passX, &amp;$passY)
   {
      $passX = ($passX - $GLOBALS[&#039;width&#039;] / 2) / $GLOBALS[&#039;scale&#039;];
      $passY = ($passY + $GLOBALS[&#039;height&#039;] / 2) / $GLOBALS[&#039;scale&#039;];
   }

   // The plot function simply takes Cartesian coordinates and
   // plots a dot on the screen
   function plot($passGraphic, $passCartX, $passCartY)
   {
      // We use green for our graphs
      $plotColor = imagecolorallocate($passGraphic, 0, 255, 0);

      // Convert Cartesian coordinates to image coordinates
      cartToPixels($passCartX, $passCartY);

      // Then draw a dot there
      imagesetpixel($passGraphic, $passCartX, $passCartY, $plotColor);
   }

   // Push out an image/png mime type to the browser so it knows
   // a PNG image is coming and not HTML
   header (&quot;Content-type: image/png&quot;);

   // Create a new image resource with the dimensions dictated
   // by our width and height globals.  Starts off with a black
   // background automatically.
   $im = @imagecreatetruecolor($GLOBALS[&#039;width&#039;], $GLOBALS[&#039;height&#039;])
      or die(&quot;Cannot Initialize new GD image stream&quot;);

   // Draw the grid on our graph first (under everything)
   drawGrid($im);

   // We start a loop from 0 (First pixel in width of graph) to the width end,
   // converting image X coordinate to Cartesian X coordinate, then retrieving
   // the corresponding Y Cartesian coordinate (remember, our equations are
   // in &#039;y =&#039; form.  We multiply it by 50 to give a better resolution - e.g. multiple dots on
   // the Y axis for each X.  This gives us a solid line instead of a bunch of dots for steep
   // functions.  The higher the number, the smoother the line (and the slower the program)
   for ($lcv = 0 ; $lcv &lt; $GLOBALS[&#039;width&#039;] * 50 / $GLOBALS[&#039;scale&#039;] ; $lcv++)
   {
      // Get the left most point on the graph in Cartesian coordinates
      $tempX = 0;
      $tempY = 0;
      pixelsToCart($tempX, $tempY);

      // Now get the current Cartesian X coordinate by adding our current loop
      // value divided by 50
      $tempX += $lcv/50;

      // Here&#039;s where the magic happens.  In a nutshell, we&#039;re setting the Y coordinate
      // ($tempY) in relation to the current X coordinate ($tempX)
      // by using the expression specified by the user.  We use PHP&#039;s eval function,
      // which allows us to take a string (the user&#039;s input box) and run it as if it
      // were PHP code.  We&#039;re also converting X to $tempX because that&#039;s the actual
      // name of our X variable in our code, not just
      // &#039;X&#039; - but we don&#039;t want the user to have to type &#039;$tempX&#039;, so we make it easy for
      // them.  This is the line of code to be especially careful of, as a user could insert
      // malicious PHP code and do bad things.
      @eval(&quot;\$tempY = &quot; . str_replace(&#039;X&#039;, &#039;$tempX&#039;, $_POST[&#039;tempBox&#039;]) . &quot;;&quot;);

       // Now that we have both coordinates, we plot it!
      plot($im, $tempX, $tempY);
   }

   // We write the equation on the graph in red
   $textColor = imagecolorallocate($im, 255, 0, 0);

   // Now write the equation on the graph
   imagestring($im, 4, 10, $GLOBALS[&#039;height&#039;] - 25, &#039;y = &#039; . $_POST[&#039;tempBox&#039;], $textColor);

   // Output a PNG file now that it&#039;s all built
   imagepng($im);

   // Free up the resource
   imagedestroy($im);
}
else
{
? &gt;

&lt;html&gt;
   &lt;body&gt;

      &lt;div style=&quot;margin-bottom:20px; font-weight:bold; font-size:16px&quot;&gt;Simple Grapher&lt;/div&gt;

      &lt;form id=&quot;graphForm&quot; action=&quot;?&lt; ? php echo rand(); ? &gt;&quot; method=&quot;post&quot;&gt;
         Enter expression: y = &lt;input type=&quot;input&quot; id=&quot;tempBox&quot; name=&quot;tempBox&quot;&gt; &lt;input type=&quot;submit&quot; value=&quot;Graph!&quot;&gt;
      &lt;/form&gt;

      &lt;div style=&quot;margin-bottom:15px&quot;&gt;Enter expression using variable X (PHP code accepted).  Both axes in range of -250 to 250.&lt;/div&gt;
      &lt;div&gt;Examples:
         &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;javascript:populate(&#039;cos(X / 30) * 50&#039;)&quot;&gt;cos(X / 30) * 50&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;javascript:populate(&#039;pow(X / 30, 3) - X&#039;)&quot;&gt;pow(X / 30, 3) - X&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;javascript:populate(&#039;pow(X, 2) / 15 - 200&#039;)&quot;&gt;pow(X, 2) / 15 - 200&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;javascript:populate(&#039;2000 / X&#039;)&quot;&gt;2000 / X&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;javascript:populate(&#039;tan(X/ 25) * 20&#039;)&quot;&gt;tan(X/ 25) * 20&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;javascript:populate(&#039;-3 * X + 50&#039;)&quot;&gt;-3 * X + 50&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;javascript:populate(&#039;rand() % X&#039;)&quot;&gt;rand() % X&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;javascript:populate(&#039;pow(X,2) % X - X&#039;)&quot;&gt;pow(X,2) % X - X&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;javascript:populate(&#039;pow(X,2) % X - cos(X/20) * 40&#039;)&quot;&gt;pow(X,2) % X - cos(X/20) * 40 (favorite)&lt;/a&gt;&lt;/li&gt;
         &lt;/ul&gt;
      &lt;/div&gt;
   &lt;/body&gt;
&lt;/html&gt;

&lt; script type=&quot;text/javascript&quot;&gt;

   function populate(passExpression)
   {
      document.getElementById(&#039;tempBox&#039;).value = passExpression;
      document.getElementById(&#039;graphForm&#039;).submit();
   }

&lt; /script&gt;

&lt; ? php
}
? &gt;
</pre>
</div>
<p>That&#8217;s it &#8211; a few things to note:  We tack on a random value to the URL (check out the form code in the HTML section) to ensure our browser doesn&#8217;t show a cached copy of the image.  Since its always using the same filename, the browser would almost certainly show old copies unless a refresh was requested or cache was cleared (depending on the browser).  </p>
<p>As you might have seen from the code, generating images is very easy in PHP.  We can create a new image resource using the <em>imagecreatetruecolor</em> function.  This creates a blank resource, we can also create from preexisting images.  Once we have an image resource, we can perform basic graphic functions on it like lines, dots, fill, text, etc.  Once we&#8217;re done, the <em>imagepng</em> function can convert it into actual PNG binary code (in our case we dump it to the browser, but you can specify a filename too to save it to).  </p>
<p>It&#8217;s definitely fun to play around with the graphic library, you can do a lot of neat things and add some needed graphics to normally text-only server side output.  Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.toniwestbrook.com/archives/68/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Rotate, Flip, and Resize Images in .NET</title>
		<link>http://www.toniwestbrook.com/archives/60</link>
		<comments>http://www.toniwestbrook.com/archives/60#comments</comments>
		<pubDate>Mon, 10 Mar 2008 04:33:40 +0000</pubDate>
		<dc:creator>Toni</dc:creator>
				<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.toniwestbrook.com/archives/60</guid>
		<description><![CDATA[Often times if you’re writing a web application that deals with user uploaded photographs and other images, a nice feature set to have is one that allows users to do basic manipulations on their photos, such as rotating, flipping, and resizing (the last being very important for download friendly images). Luckily, the .NET framework makes [...]]]></description>
			<content:encoded><![CDATA[<p>Often times if you’re writing a web application that deals with user uploaded photographs and other images, a nice feature set to have is one that allows users to do basic manipulations on their photos, such as rotating, flipping, and resizing (the last being very important for download friendly images).  Luckily, the .NET framework makes such functionality easy to implement.</p>
<p><strong>Read the Image</strong></p>
<p>Once the image has been uploaded and saved into a directory somewhere accessible by the web server, the first step common to all the procedures is to take the image data inside of the file and get it into memory usable by .NET.  We do this by loading the image into a System.Drawing.Bitmap object.  One of the constructors of Bitmap class can take the filename of an image, thereby automatically decoding the format and reading in the data into the Bitmap object.  .NET supports the most common image formats, such as JPEG, GIF, BMP, and PNG.  </p>
<pre lang="vbnet">
        Dim PhotoBMP As Bitmap

        PhotoBMP = New Bitmap(“myfile.jpg”)
</pre>
<p>Above we have statically specified a filename, but you may, of course, dynamically pass in the filename saved on the webserver.</p>
<p><strong>Flips and Rotations</strong></p>
<p>Reorienting the image is incredibly easy.  The Bitmap class contains a method called “RotateFlip” that does what you would think – rotates and/or flips.  The RotateFlip method takes a single argument, one of RotateFlipType type.  Intellisense will enumerate all the options, but each combination of rotation and flip is included: 90, 180, 270 degrees, and flips across X, Y or both axes.  </p>
<pre lang="vbnet">
        PhotoBMP.RotateFlip(RotateFlipType.Rotate270FlipNone)
</pre>
<p>Above we rotate our image clockwise 270 degrees (i.e. counter-clockwise 90 degrees).  We do not perform a flip.  </p>
<pre lang="vbnet">
        PhotoBMP.RotateFlip(RotateFlipType.RotateNoneFlipY)
</pre>
<p>Above we flip our image across the Y axis but do not perform a rotation.  You may also combine both flips and rotations simultaneously if desired.</p>
<p><strong>Saving (and Converting) the Image</strong></p>
<p>At this point, our reorientation has only been performed upon the bitmap data we have in memory, our file is still untouched.  We can save our changes back to the original file, or to a new file if desired.  The Bitmap class contains an easy to use Save method.</p>
<pre lang="vbnet">
        PhotoBMP.Save(“myfile.jpg”)
</pre>
<p>Save is overloaded in a number of ways, but you may also specify a filetype as the second argument.  In our example, if we wanted to convert our jpg to a png:</p>
<pre lang="vbnet">
        PhotoBMP.Save(“myfile.png”,ImageFormat.Png)
</pre>
<p>Very easy as can be seen, no need to lookup file formats and encodings.  You may also want to read in the current extension to direct what actions are taken.  I use the following regular expression to parse the ending extension of the file.</p>
<pre lang="vbnet">
        Regex.Match(FileName, ".[^.]+$")
</pre>
<p><strong>Resizing Images</strong></p>
<p>Resizing images is a little more difficult, but not too bad once you know the procedure.  You start by loading bitmap data in the same fashion we did for rotating and flipping.  Assuming you want to keep the image in proportion when changing the size, as well as resize with a maximum resolution in mind, we’ll need to calculate the aspect ratio of the image and our conversion coefficient.  This may sound complicated, but fear not.  </p>
<p><strong>Calculate Aspect Ratio</strong></p>
<p>There are a few methods of doing the math, but in general we know the maximum dimension we want.  E.g. 1024&#215;768, 800&#215;600, 640&#215;480, etc.  We calculate the aspect ratio of our maximum desired size by dividing the width by the height.  In these examples it is 1.333.  </p>
<p>Then we must calculate the aspect ratio of the current image.  We can obtain the width and height of our bitmap with the width and height properties of the Bitmap class.  We know if we have a greater aspect ratio than our target max size’s aspect ratio, then our width is larger and is the confining dimension.  If our aspect ratio is less, our height is larger and is the confining dimension.  Once we know our confining dimension, to get the conversion coefficient, we divide our current image confining dimension size by the target confining dimension size.  </p>
<p>E.g. If we’re converting 2048&#215;1800 to a maximum of 1024&#215;768, we calculate our target image aspect ratio, which we already know is 1.333.  Then we calculate our original image aspect ratio, which is 1.138.  This is less than 1.333, so we know height is our confining dimension.  So we divide 1800 by 768 to get our conversion coefficient, or 2.344.  Now we can calculate our target width size by dividing our current width by 2.344, which is 874.  Our new image will by 874&#215;768.</p>
<p>Confused?  It’s not really as bad as it sounds.  First you’re figuring out which dimension will match the largest dimension of your target size, then you’re decreasing the other dimension by the same amount.  Here it is in code.</p>
<pre lang="vbnet">
        OrigAspectRatio = PhotoBMP.Width / PhotoBMP.Height

        TargetAspectRatio = 1024 / 768

        If OrigAspectRatio < TargetAspectRatio
   	     ‘Height is confining
	     NewHeight = 768
	     NewWidth = PhotoBMP.Width / (PhotoBMP.Height / 768)
        Else
	     ‘Width is confining
	     NewWidth = 1024
  	     NewHeight = PhotoBMP.Height / (PhotoBMP.Width / 1024)
        End If
</pre>
<p><strong>Perform the Resize</strong></p>
<p>Now we have our target width and height via good old fashioned math, now the technical bits for .NET to perform its magic.  .NET can perform resizing via the Graphics class, by resizing data from the original bitmap data into a new, smaller bitmap.  First we make a new, blank Bitmap of the correct new size.</p>
<pre lang="vbnet">
        NewBMP = New Bitmap(newWidth, newHeight)
</pre>
<p>Then we create a new Graphics image using the reference of this new Bitmap object.</p>
<pre lang="vbnet">
        ConvertGraphics = Graphics.FromImage(NewBMP)
</pre>
<p>Then we specify the method of scaling the image.  Different methods work better for different amounts of scaling, but High Quality Bicubic is the one I tend to use.  </p>
<pre lang="vbnet">
        ConvertGraphics.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
</pre>
<p>Now comes the actual conversion, we use the DrawImage method to draw our original bitmap into the new bitmap at the new size (at the starting coordinates of 0,0 in the new bitmap</p>
<pre lang="vbnet">
        ConvertGraphics.DrawImage(PhotoBMP, 0, 0, NewBMP.Width, NewBMP.Height)
</pre>
<p>Dispose our old bitmap</p>
<pre lang="vbnet">
        PhotoBMP.Dispose()
</pre>
<p>Save our new</p>
<pre lang="vbnet">
        NewBMP.Save(“new.jpg”, ImageFormat.Jpeg)
</pre>
<p>And dispose</p>
<pre lang="vbnet">
        NewBMP.Dispose()
</pre>
<p>And we’re done!  You can also use the Graphics object to perform a number of paint-oriented operations on your image, such as lines and drawing text, but that you can have fun experimenting with.</p>
<p>With the exception of resizing which requires a few calculations, .NET makes image manipulation exteremly easy, and when combined into a web application, offers users some useful tools at virtually no cost to you.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.toniwestbrook.com/archives/60/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

