<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: maximum code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 18 May 2008 12:24:58 GMT</pubDate>
    <description>DZone Snippets: maximum code</description>
    <item>
      <title>C#: Resize An Image While Maintaining Aspect Ratio and Maximum Height</title>
      <link>http://snippets.dzone.com/posts/show/4336</link>
      <description>// This allows us to resize the image. It prevents skewed images and &lt;br /&gt;// also vertically long images caused by trying to maintain the aspect &lt;br /&gt;// ratio on images who's height is larger than their width&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;public void ResizeImage(string OriginalFile, string NewFile, int NewWidth, int MaxHeight, bool OnlyResizeIfWider)&lt;br /&gt;{&lt;br /&gt;	System.Drawing.Image FullsizeImage = System.Drawing.Image.FromFile(OriginalFile);&lt;br /&gt;&lt;br /&gt;	// Prevent using images internal thumbnail&lt;br /&gt;	FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);&lt;br /&gt;	FullsizeImage.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipNone);&lt;br /&gt;&lt;br /&gt;	if (OnlyResizeIfWider)&lt;br /&gt;	{&lt;br /&gt;		if (FullsizeImage.Width &lt;= NewWidth)&lt;br /&gt;		{&lt;br /&gt;			NewWidth = FullsizeImage.Width;&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	int NewHeight = FullsizeImage.Height * NewWidth / FullsizeImage.Width;&lt;br /&gt;	if (NewHeight &gt; MaxHeight)&lt;br /&gt;	{&lt;br /&gt;		// Resize with height instead&lt;br /&gt;		NewWidth = FullsizeImage.Width * MaxHeight / FullsizeImage.Height;&lt;br /&gt;		NewHeight = MaxHeight;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	System.Drawing.Image NewImage = FullsizeImage.GetThumbnailImage(NewWidth, NewHeight, null, IntPtr.Zero);&lt;br /&gt;&lt;br /&gt;	// Clear handle to original file so that we can overwrite it if necessary&lt;br /&gt;	FullsizeImage.Dispose();&lt;br /&gt;&lt;br /&gt;	// Save resized picture&lt;br /&gt;	NewImage.Save(NewFile);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 19 Jul 2007 22:55:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4336</guid>
      <author>cornerblue (CornerBLUE, Inc.)</author>
    </item>
    <item>
      <title>max-of function</title>
      <link>http://snippets.dzone.com/posts/show/1087</link>
      <description>&lt;code&gt;&lt;br /&gt;    ; This returns only the maximum value out of context maximum-of returns the series&lt;br /&gt;    ; at the position of the maximum value found.&lt;br /&gt;    max-of: func [series [series!]] [attempt [first maximum-of series]]&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 10 Jan 2006 05:19:03 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1087</guid>
      <author>gregg.irwin (Gregg Irwin)</author>
    </item>
  </channel>
</rss>
