<?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>XIU&#039;s Blog &#187; .NET 4.0</title>
	<atom:link href="http://xiu.shoeke.com/tags/net-4-0/feed/" rel="self" type="application/rss+xml" />
	<link>http://xiu.shoeke.com</link>
	<description>.NET, Vidyano, WPF, Design Patterns, Ruby, Random Thoughts, ...</description>
	<lastBuildDate>Thu, 20 Oct 2011 07:47:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Resizing images with WPF 4.0</title>
		<link>http://xiu.shoeke.com/2010/07/15/resizing-images-with-wpf-4-0/</link>
		<comments>http://xiu.shoeke.com/2010/07/15/resizing-images-with-wpf-4-0/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 22:18:34 +0000</pubDate>
		<dc:creator>XIU</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Resizer]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://xiu.shoeke.com/?p=107</guid>
		<description><![CDATA[Microsoft changed the default behaviour for scaling images with WPF 4.0/.NET 4.0. They opted for a faster but less accurate scaling algorithm named Linear instead of the default Fant that was used in WPF 3.0. You can change this behaviour using the &#8230; <a href="http://xiu.shoeke.com/2010/07/15/resizing-images-with-wpf-4-0/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Microsoft changed the default behaviour for scaling images with WPF 4.0/.NET 4.0.<br />
They opted for a faster but less accurate scaling algorithm named Linear instead of the default Fant that was used in WPF 3.0.</p>
<p>You can change this behaviour using the <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.renderoptions.bitmapscalingmode.aspx">RenderOptions.BitmapScalingMode</a> attached property.</p>
<pre class="brush: xml">&lt;Image Source="Image.png"
    RenderOptions.BitmapScalingMode="HighQuality" /&gt;</pre>
<p>Microsoft recommends to only use HighQuality if the image&#8217;s scaled size will be less that 30-50% of the original size.</p>
<p>The <a title="resizer.codeplex.com" href="http://resizer.codeplex.com/">Resizer </a>application will always use HighQuality so that it gives the best image quality for any image.</p>
<p>Using the attached property on images scaled in code using DrawingVisual/<a title="RenderTargetBitmap Class" href="http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.rendertargetbitmap.aspx">RenderTargetBitmap</a> requires a bit of special code.</p>
<pre class="brush: csharp">private static BitmapFrame CreateResizedImage(ImageSource source, int width, int height, int margin)
{
    var rect = new Rect(margin, margin, width - margin * 2, height - margin * 2);

    var group = new DrawingGroup();
    RenderOptions.SetBitmapScalingMode(group, BitmapScalingMode.HighQuality);
    group.Children.Add(new ImageDrawing(source, rect));

    var drawingVisual = new DrawingVisual();
    using (var drawingContext = drawingVisual.RenderOpen())
        drawingContext.DrawDrawing(group);

    var resizedImage = new RenderTargetBitmap(
        width, height,         // Resized dimensions
        96, 96,                // Default DPI values
        PixelFormats.Default); // Default pixel format
    resizedImage.Render(drawingVisual);

    return BitmapFrame.Create(resizedImage);
}</pre>
<p>Width and height contains the margin already, so if the image is scaled to 300px with a margin of 10px then the method will be called with width = 320px and margin = 10px. We can use the DrawingGroup to set the BitmapScalingMode and then add the ImageDrawing to it.</p>
]]></content:encoded>
			<wfw:commentRss>http://xiu.shoeke.com/2010/07/15/resizing-images-with-wpf-4-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resizer</title>
		<link>http://xiu.shoeke.com/2010/07/14/resizer/</link>
		<comments>http://xiu.shoeke.com/2010/07/14/resizer/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 03:52:10 +0000</pubDate>
		<dc:creator>XIU</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[Resizer]]></category>
		<category><![CDATA[Vidyano]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://xiu.shoeke.com/?p=96</guid>
		<description><![CDATA[I&#8217;ve been working on a little project to demo the features of Vidyano. It&#8217;s used internally to generate the thumbnails for our Wiki. The source code is available on codeplex and the application is deployed as click-once. I&#8217;ll be talking about &#8230; <a href="http://xiu.shoeke.com/2010/07/14/resizer/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a little project to demo the features of <a href="http://www.vidyano.com/">Vidyano</a>.<a href="http://xiu.shoeke.com/wp-content/uploads/2010/07/PreviewResizer.png"><img class="alignnone size-full wp-image-97" title="Resizer Preview" src="http://xiu.shoeke.com/wp-content/uploads/2010/07/PreviewResizer.png" alt="" width="620" height="527" /></a></p>
<p>It&#8217;s used internally to generate the thumbnails for our <a href="http://www.vidyano.com/Wiki/Home">Wiki</a>. The source code is available on <a href="http://resizer.codeplex.com/">codeplex</a> and the application is deployed as <a href="http://resizer.codeplex.com/releases/clickonce/">click-once</a>.</p>
<p>I&#8217;ll be talking about the specific Vidyano features and the resizing part with WPF 4 in the next blog posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://xiu.shoeke.com/2010/07/14/resizer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vidyano 2.0 released</title>
		<link>http://xiu.shoeke.com/2010/07/01/vidyano-2-0-released/</link>
		<comments>http://xiu.shoeke.com/2010/07/01/vidyano-2-0-released/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 13:42:17 +0000</pubDate>
		<dc:creator>XIU</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.NET 4.0]]></category>
		<category><![CDATA[MEF]]></category>
		<category><![CDATA[MVVM]]></category>
		<category><![CDATA[Reactive Extensions]]></category>
		<category><![CDATA[Vidyano]]></category>

		<guid isPermaLink="false">http://xiu.shoeke.com/?p=86</guid>
		<description><![CDATA[I&#8217;m proud to announce that our team has finished our next major version of Vidyano. Build from scratch to optimize everything for the latest .NET 4.0 release and using all latest features of it (MEF, Rx, &#8230;). The User Interface &#8230; <a href="http://xiu.shoeke.com/2010/07/01/vidyano-2-0-released/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m proud to announce that our team has finished our next major version of Vidyano.<br />
Build from scratch to optimize everything for the latest .NET 4.0 release and using all latest features of it (MEF, Rx, &#8230;).<br />
The User Interface now uses a MVVM based architecture with our Module/Page system on top of it.</p>
<p>You can download it directly from inside Visual Studio using the Extension Manager or at the <a href="http://visualstudiogallery.msdn.microsoft.com/en-us/8367485B-8372-4B44-A118-3C40B8EA9C15">Visual Studio Gallery Page</a>.</p>
<p>Read more on our <a href="http://blog.vidyano.com/post/Vidyano-20-now-available-on-the-Microsoft-Visual-Studio-Extension-Gallery.aspx">blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://xiu.shoeke.com/2010/07/01/vidyano-2-0-released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.435 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-01-07 19:08:01 -->

