<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>XIU's Blog</title>
	
	<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>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/xiu" /><feedburner:info uri="xiu" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Vidyano Blog</title>
		<link>http://feedproxy.google.com/~r/xiu/~3/4PIuVq6xlkI/</link>
		<comments>http://xiu.shoeke.com/2011/10/20/vidyano-blog/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 07:47:47 +0000</pubDate>
		<dc:creator>XIU</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Vidyano]]></category>

		<guid isPermaLink="false">http://xiu.shoeke.com/?p=147</guid>
		<description><![CDATA[We decided to also use a new blog for Vidyano. This will allow us to post some of the ideas or difficulties we had when implementing some of our features, features or questions we got from our users or when &#8230; <a href="http://xiu.shoeke.com/2011/10/20/vidyano-blog/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We decided to also use a new blog for Vidyano. This will allow us to post some of the ideas or difficulties we had when implementing some of our features, features or questions we got from our users or when we need to request some feedback from our users.</p>
<p><a href="http://blog.vidyano.com/">More info</a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/gajPEQzWhL51mdW3NSAKlz7mnFI/0/da"><img src="http://feedads.g.doubleclick.net/~a/gajPEQzWhL51mdW3NSAKlz7mnFI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/gajPEQzWhL51mdW3NSAKlz7mnFI/1/da"><img src="http://feedads.g.doubleclick.net/~a/gajPEQzWhL51mdW3NSAKlz7mnFI/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/xiu/~4/4PIuVq6xlkI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://xiu.shoeke.com/2011/10/20/vidyano-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://xiu.shoeke.com/2011/10/20/vidyano-blog/</feedburner:origLink></item>
		<item>
		<title>Vidyano 3.0 released</title>
		<link>http://feedproxy.google.com/~r/xiu/~3/4G4ydTFgC84/</link>
		<comments>http://xiu.shoeke.com/2011/10/10/vidyano-3-0-released/#comments</comments>
		<pubDate>Mon, 10 Oct 2011 18:12:04 +0000</pubDate>
		<dc:creator>XIU</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Vidyano]]></category>

		<guid isPermaLink="false">http://xiu.shoeke.com/?p=145</guid>
		<description><![CDATA[I&#8217;m proud to announce the release of our third version of Vidyano. This version we focused on the integration with the cloud, so you can take your application and publish it to the cloud without having to make a single &#8230; <a href="http://xiu.shoeke.com/2011/10/10/vidyano-3-0-released/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m proud to announce the release of our third version of Vidyano. This version we focused on the integration with the cloud, so you can take your application and publish it to the cloud without having to make a single change.</p>
<p>We uploaded some <a href="http://www.vidyano.com/Developer/Videos">videos</a> to show some of the features.</p>
<p><a href="http://www.vidyano.com/">More info</a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/kulX_i_N1xAFkgLvo1aGCXkrlHE/0/da"><img src="http://feedads.g.doubleclick.net/~a/kulX_i_N1xAFkgLvo1aGCXkrlHE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/kulX_i_N1xAFkgLvo1aGCXkrlHE/1/da"><img src="http://feedads.g.doubleclick.net/~a/kulX_i_N1xAFkgLvo1aGCXkrlHE/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/xiu/~4/4G4ydTFgC84" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://xiu.shoeke.com/2011/10/10/vidyano-3-0-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://xiu.shoeke.com/2011/10/10/vidyano-3-0-released/</feedburner:origLink></item>
		<item>
		<title>Snoop v2.7 released</title>
		<link>http://feedproxy.google.com/~r/xiu/~3/9VFlG8L3L3Q/</link>
		<comments>http://xiu.shoeke.com/2011/09/04/snoop-v2-7-released/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 23:28:27 +0000</pubDate>
		<dc:creator>XIU</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://xiu.shoeke.com/?p=141</guid>
		<description><![CDATA[A new version has been released (download here) of this must have WPF utility. The biggest change is that you can drop a crosshair in the application that you want to snoop so that you no longer have to wait &#8230; <a href="http://xiu.shoeke.com/2011/09/04/snoop-v2-7-released/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A new version has been released (<a href="http://snoopwpf.codeplex.com/releases/view/60745">download here</a>) of this must have WPF utility. The biggest change is that you can drop a crosshair in the application that you want to snoop so that you no longer have to wait for the combobox to be filled with all possible applications.</p>
<p><a href="http://snoopwpf.codeplex.com/">More info&#8230;</a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/j4BpAe8oxgNd4z8f6iDRNqO0bWg/0/da"><img src="http://feedads.g.doubleclick.net/~a/j4BpAe8oxgNd4z8f6iDRNqO0bWg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/j4BpAe8oxgNd4z8f6iDRNqO0bWg/1/da"><img src="http://feedads.g.doubleclick.net/~a/j4BpAe8oxgNd4z8f6iDRNqO0bWg/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/xiu/~4/9VFlG8L3L3Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://xiu.shoeke.com/2011/09/04/snoop-v2-7-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://xiu.shoeke.com/2011/09/04/snoop-v2-7-released/</feedburner:origLink></item>
		<item>
		<title>Happy Newyear</title>
		<link>http://feedproxy.google.com/~r/xiu/~3/VyFLDUQOI9c/</link>
		<comments>http://xiu.shoeke.com/2011/01/01/happy-newyear-3/#comments</comments>
		<pubDate>Fri, 31 Dec 2010 22:00:55 +0000</pubDate>
		<dc:creator>XIU</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://xiu.shoeke.com/?p=134</guid>
		<description><![CDATA[Here&#8217;s to a happy new year]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s to a happy new year <img src='http://xiu.shoeke.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<p><a href="http://feedads.g.doubleclick.net/~a/ixfbxuedzpdaD87GbZ6uAVD2Ylo/0/da"><img src="http://feedads.g.doubleclick.net/~a/ixfbxuedzpdaD87GbZ6uAVD2Ylo/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ixfbxuedzpdaD87GbZ6uAVD2Ylo/1/da"><img src="http://feedads.g.doubleclick.net/~a/ixfbxuedzpdaD87GbZ6uAVD2Ylo/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/xiu/~4/VyFLDUQOI9c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://xiu.shoeke.com/2011/01/01/happy-newyear-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://xiu.shoeke.com/2011/01/01/happy-newyear-3/</feedburner:origLink></item>
		<item>
		<title>Using DrawingBrush to handle transparent backgrounds</title>
		<link>http://feedproxy.google.com/~r/xiu/~3/kEENL2PXLQk/</link>
		<comments>http://xiu.shoeke.com/2010/07/19/using-drawingbrush-to-handle-transparent-backgrounds/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 20:52:16 +0000</pubDate>
		<dc:creator>XIU</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://xiu.shoeke.com/?p=127</guid>
		<description><![CDATA[With images it is sometimes difficult to see the difference between a white and transparent background. Using a DrawingBush in Tile mode can create the known checker background used in applications as Photoshop. &#60;DrawingBrush&#62; &#60;DrawingBrush.Drawing&#62; &#60;DrawingGroup&#62; &#60;GeometryDrawing Brush="White"&#62; &#60;GeometryDrawing.Geometry&#62; &#60;RectangleGeometry Rect="0,0,10,10" /&#62; &#8230; <a href="http://xiu.shoeke.com/2010/07/19/using-drawingbrush-to-handle-transparent-backgrounds/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>With images it is sometimes difficult to see the difference between a white and transparent background. Using a DrawingBush in Tile mode can create the known checker background used in applications as Photoshop.</p>
<pre class="brush: xml">&lt;DrawingBrush&gt;
    &lt;DrawingBrush.Drawing&gt;
        &lt;DrawingGroup&gt;
            &lt;GeometryDrawing Brush="White"&gt;
                &lt;GeometryDrawing.Geometry&gt;
                    &lt;RectangleGeometry Rect="0,0,10,10" /&gt;
                &lt;/GeometryDrawing.Geometry&gt;
            &lt;/GeometryDrawing&gt;
            &lt;GeometryDrawing Brush="LightGray"&gt;
                &lt;GeometryDrawing.Geometry&gt;
                    &lt;GeometryGroup&gt;
                        &lt;RectangleGeometry Rect="0,0,5,5" /&gt;
                        &lt;RectangleGeometry Rect="5,5,5,5" /&gt;
                    &lt;/GeometryGroup&gt;
                &lt;/GeometryDrawing.Geometry&gt;
            &lt;/GeometryDrawing&gt;
        &lt;/DrawingGroup&gt;
    &lt;/DrawingBrush.Drawing&gt;
&lt;/DrawingBrush&gt;</pre>
<p>Which will give the following effect if used as the background property.</p>
<p><img class="alignnone size-full wp-image-129" title="TransparentBackground" src="http://xiu.shoeke.com/wp-content/uploads/2010/07/TransparentBackground.png" alt="" width="143" height="134" /></p>

<p><a href="http://feedads.g.doubleclick.net/~a/DpYskcouOmRyCeRPdMXZnh_JPxM/0/da"><img src="http://feedads.g.doubleclick.net/~a/DpYskcouOmRyCeRPdMXZnh_JPxM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/DpYskcouOmRyCeRPdMXZnh_JPxM/1/da"><img src="http://feedads.g.doubleclick.net/~a/DpYskcouOmRyCeRPdMXZnh_JPxM/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/xiu/~4/kEENL2PXLQk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://xiu.shoeke.com/2010/07/19/using-drawingbrush-to-handle-transparent-backgrounds/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://xiu.shoeke.com/2010/07/19/using-drawingbrush-to-handle-transparent-backgrounds/</feedburner:origLink></item>
		<item>
		<title>WPF Image Buttons</title>
		<link>http://feedproxy.google.com/~r/xiu/~3/ovqBbcTvNGE/</link>
		<comments>http://xiu.shoeke.com/2010/07/16/wpf-image-buttons/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 12:40:13 +0000</pubDate>
		<dc:creator>XIU</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Resizer]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://xiu.shoeke.com/?p=121</guid>
		<description><![CDATA[For my Resizer application I wanted a toolbar with image buttons, everything was perfect until I tried to disable the buttons. The first idea was to add a greyscale effect to the button if it was disabled. For a complete &#8230; <a href="http://xiu.shoeke.com/2010/07/16/wpf-image-buttons/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For my <a href="http://resizer.codeplex.com/">Resizer</a> application I wanted a toolbar with image buttons, everything was perfect until I tried to disable the buttons. The first idea was to add a greyscale effect to the button if it was disabled. For a complete black/white icon this didn&#8217;t help either but changing the opacity does.</p>
<p><img class="alignnone size-full wp-image-124" title="Toolbar-WithDisabled" src="http://xiu.shoeke.com/wp-content/uploads/2010/07/Toolbar-WithDisabled.png" alt="" width="106" height="35" /><br />
<em>Save/Clear disabled because there are no images </em></p>
<p><img class="alignnone size-full wp-image-122" title="Toolbar-AllEnabled" src="http://xiu.shoeke.com/wp-content/uploads/2010/07/Toolbar-AllEnabled.png" alt="" width="102" height="36" /><br />
<em>All buttons enabled</em></p>
<p><img class="alignnone size-full wp-image-123" title="Toolbar-MouseOver" src="http://xiu.shoeke.com/wp-content/uploads/2010/07/Toolbar-MouseOver.png" alt="" width="103" height="33" /><br />
<em>MouseOver Save button</em></p>
<pre class="brush: xml">    &lt;Style TargetType="Button"&gt;
        &lt;Setter Property="Template"&gt;
            &lt;Setter.Value&gt;
                &lt;ControlTemplate TargetType="Button"&gt;
                    &lt;Grid Margin="1"&gt;
                        &lt;Rectangle x:Name="OuterBorder" RadiusY="2" RadiusX="2" Visibility="Collapsed"/&gt;
                        &lt;Rectangle x:Name="Bg" Fill="{TemplateBinding Background}" Margin="1" RadiusY="1" RadiusX="1" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" Visibility="Collapsed"/&gt;
                        &lt;Rectangle x:Name="InnerBorder" Margin="2" Visibility="Collapsed"/&gt;
                        &lt;ContentPresenter Margin="5" VerticalAlignment="Center" /&gt;
                    &lt;/Grid&gt;
                    &lt;ControlTemplate.Triggers&gt;
                        &lt;Trigger Property="IsMouseOver" Value="True"&gt;
                            &lt;Setter Property="Visibility" TargetName="OuterBorder" Value="Visible"/&gt;
                            &lt;Setter Property="Visibility" TargetName="Bg" Value="Visible"/&gt;
                            &lt;Setter Property="Visibility" TargetName="InnerBorder" Value="Visible"/&gt;
                        &lt;/Trigger&gt;
                        &lt;Trigger Property="IsEnabled" Value="False"&gt;
                            &lt;Setter Property="Effect"&gt;
                                &lt;Setter.Value&gt;
                                    &lt;effects:GreyscaleEffect /&gt;
                                &lt;/Setter.Value&gt;
                            &lt;/Setter&gt;
                            &lt;Setter Property="Opacity" Value=".5" /&gt;
                        &lt;/Trigger&gt;
                    &lt;/ControlTemplate.Triggers&gt;
                &lt;/ControlTemplate&gt;
            &lt;/Setter.Value&gt;
        &lt;/Setter&gt;
    &lt;/Style&gt;</pre>
<p>And the following .fx code is used for the greyscale effect.</p>
<pre>sampler2D  ImageSampler : register(S0);  //take ImageSampler from S0 register. 

// 'uv' vector from TEXCOORD0 semantics is our texture coordinate, two floating point numbers in the range 0-1.
float4 PS( float2 uv : TEXCOORD) : COLOR
{
    float4 color = tex2D( ImageSampler, uv); // get the color of texture at the current point
    color.rgb = dot(color.rgb, float3(0.3, 0.59, 0.11)); //compose correct luminance value
    return color;
}</pre>
<p><a title="Browse Latest" href="http://resizer.codeplex.com/SourceControl/BrowseLatest">Browse the latest source</a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/gPLYA48ob-IfgTb2ODgOlonU0kE/0/da"><img src="http://feedads.g.doubleclick.net/~a/gPLYA48ob-IfgTb2ODgOlonU0kE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/gPLYA48ob-IfgTb2ODgOlonU0kE/1/da"><img src="http://feedads.g.doubleclick.net/~a/gPLYA48ob-IfgTb2ODgOlonU0kE/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/xiu/~4/ovqBbcTvNGE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://xiu.shoeke.com/2010/07/16/wpf-image-buttons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://xiu.shoeke.com/2010/07/16/wpf-image-buttons/</feedburner:origLink></item>
		<item>
		<title>Updated Getting Started for Vidyano 2.0</title>
		<link>http://feedproxy.google.com/~r/xiu/~3/q48qu8lthj4/</link>
		<comments>http://xiu.shoeke.com/2010/07/16/updated-getting-started-for-vidyano-2-0/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 10:13:59 +0000</pubDate>
		<dc:creator>XIU</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Vidyano]]></category>

		<guid isPermaLink="false">http://xiu.shoeke.com/?p=104</guid>
		<description><![CDATA[We have updated the Getting Started tutorial and placed it on our Wiki.]]></description>
			<content:encoded><![CDATA[<p>We have updated the <a title="Getting Started" href="http://www.vidyano.com/Wiki/Getting-Started">Getting Started</a> tutorial and placed it on our <a title="Vidyano Wiki" href="http://www.vidyano.com/Wiki/Home">Wiki</a>.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/vR0dlGnempRjutLx1HlKln18Vpo/0/da"><img src="http://feedads.g.doubleclick.net/~a/vR0dlGnempRjutLx1HlKln18Vpo/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/vR0dlGnempRjutLx1HlKln18Vpo/1/da"><img src="http://feedads.g.doubleclick.net/~a/vR0dlGnempRjutLx1HlKln18Vpo/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/xiu/~4/q48qu8lthj4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://xiu.shoeke.com/2010/07/16/updated-getting-started-for-vidyano-2-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://xiu.shoeke.com/2010/07/16/updated-getting-started-for-vidyano-2-0/</feedburner:origLink></item>
		<item>
		<title>Resizing images with WPF 4.0</title>
		<link>http://feedproxy.google.com/~r/xiu/~3/34pgu_7iIcY/</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>

<p><a href="http://feedads.g.doubleclick.net/~a/iulCyZDdK9CrwfhZXoWJ5VWzbZw/0/da"><img src="http://feedads.g.doubleclick.net/~a/iulCyZDdK9CrwfhZXoWJ5VWzbZw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/iulCyZDdK9CrwfhZXoWJ5VWzbZw/1/da"><img src="http://feedads.g.doubleclick.net/~a/iulCyZDdK9CrwfhZXoWJ5VWzbZw/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/xiu/~4/34pgu_7iIcY" height="1" width="1"/>]]></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>
		<feedburner:origLink>http://xiu.shoeke.com/2010/07/15/resizing-images-with-wpf-4-0/</feedburner:origLink></item>
		<item>
		<title>Resizer</title>
		<link>http://feedproxy.google.com/~r/xiu/~3/J04ceGg1YY0/</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>

<p><a href="http://feedads.g.doubleclick.net/~a/TJ8SBQMbvDl-868thspORBYnbNg/0/da"><img src="http://feedads.g.doubleclick.net/~a/TJ8SBQMbvDl-868thspORBYnbNg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/TJ8SBQMbvDl-868thspORBYnbNg/1/da"><img src="http://feedads.g.doubleclick.net/~a/TJ8SBQMbvDl-868thspORBYnbNg/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/xiu/~4/J04ceGg1YY0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://xiu.shoeke.com/2010/07/14/resizer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://xiu.shoeke.com/2010/07/14/resizer/</feedburner:origLink></item>
		<item>
		<title>iRail.be is back online</title>
		<link>http://feedproxy.google.com/~r/xiu/~3/yn4OjvQuh-0/</link>
		<comments>http://xiu.shoeke.com/2010/07/06/irail-be-is-back-online/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 10:43:42 +0000</pubDate>
		<dc:creator>XIU</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Free Internet]]></category>

		<guid isPermaLink="false">http://xiu.shoeke.com/?p=93</guid>
		<description><![CDATA[iRail.be is a website to find train information here in Belgium, it scraped the original complicated website of the NMBS and provided a clean/simple interface to access the information. More info on the blogpost.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.irail.be/">iRail.be</a> is a website to find train information here in Belgium, it scraped the original complicated website of the NMBS and provided a clean/simple interface to access the information.</p>
<p>More info on the <a href="http://blog.tuinslak.org/2010/07/irail-is-back/">blogpost</a>.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/0SODXx4OSu7zVxVgVpOhtacVEuE/0/da"><img src="http://feedads.g.doubleclick.net/~a/0SODXx4OSu7zVxVgVpOhtacVEuE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/0SODXx4OSu7zVxVgVpOhtacVEuE/1/da"><img src="http://feedads.g.doubleclick.net/~a/0SODXx4OSu7zVxVgVpOhtacVEuE/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/xiu/~4/yn4OjvQuh-0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://xiu.shoeke.com/2010/07/06/irail-be-is-back-online/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://xiu.shoeke.com/2010/07/06/irail-be-is-back-online/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.511 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-01-10 11:32:30 -->

