In this post, we will be using the same image as used in the previous post. The image is as follows:
Let us instantiate this as a BitmapImage in the Resources section of Window.
<Window x:Class="WPFComboBoxEditable.WindowImageDecodedSize"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowImageDecodedSize" >
<Window.Resources>
<BitmapImage UriSource="C:\Chundrigar.jpg" x:Key="image1"
DecodePixelWidth="200" DecodePixelHeight="150" />
</Window.Resources>
<Grid>
<Image Source="{StaticResource image1}" Height="200" Width="150" />
</Grid>
</Window>
As you can see that we have specified the DecodePixelWidth and DecodePixelHeight for BitmapImage. This would cache the image as the size specified. Since we are showing the image in the same size in <Image>, it would be shown as follows:
This would definitely save a lot in terms of memory usage of the application.
No comments:
Post a Comment