title: BitmapImage DecodePixelWidth odd behavior
body: <p>I was experiencing some performance issues when displaying a large number of images, I discovered the issue was that the full resolution image was being used when I really only needed an image less than 1/4 of the size. So I added a line in between BeginInit and EndInit to set the DecodePixelWidth to 200 which is the max width I will need in my layout. My performance was no longer an issue but some of the images are really small, definitely nowhere close to 200 pixels wide. Most of the images seemed to display correctly, and there doesn't seem to be any rhyme or reason to which are too small and which work correctly. I thought it might be due to differences in the original dimensions of the images but there was no pattern to the results. I tried bumping the width up to 600 which then allowed the offending images to display at the correct width of 200 but the performance then suffers.</p>
  
  <p>At this point I am not even sure where to start looking, and would be really grateful for a kick in the right direction.</p>
  
  <p>EDIT: Some more information below about the images and how I am using them.</p>
  
  <p>Most of the images are around 1000X1500 although some have odd dimensions like 1000x1513. All of the images are JPEG. Currently each image is placed in a custom user control that I designed, nothing too fancy just a background around it with some text. Each user control is then placed in a grid, in its own row/column. The grid is inside a scrollviewer so the user can scroll through the list. This might not be the best way to accomplish what I am looking for but its what I came up with quickly and it works for the most part. Id be happy to switch to another method of display if it would accomplish what i want in an easier or more concise way.</p>
  
  <p>The intended result is for a movie browsing app. There will be a scrollable list of movies, each represented as its own tile complete with title, movie poster, genre info, rating, and description. This list will be sortable on various items. The information about the movies is stored in a sql database on another machine. The images are originally stored on another machine but are copied locally to improve performance.</p>
  
  <p>EDIT: I have been able to solve the issue by not using DecodePixelWidth and instead saving a copy of the image at the desired size, this has improved performance. Youngjae's recommendation of not using DecodePixelWidth along with his mention of using a virtualized list led me to the following set of articles on creating a Virtualized Wrap Panel which should solve any other performance issues. The article is for silverlight but from what I understand silverlight is basically a watered down version of wpf, if it works in silverlight it should work in wpf. It shouldn't be too difficult to convert it for my use.</p>
  
  <p><a href="http://blogs.claritycon.com/blog/2009/08/custom-panels-in-silverlight-wpf-part-1-measureoverride/" rel="nofollow">Part 1 - MeasureOverride</a></p>
  
  <p><a href="http://blogs.claritycon.com/blog/2009/08/custom-panels-in-silverlight-wpf-part-2-arrangeoverride/" rel="nofollow">Part 2 - ArrangeOverride</a></p>
  
  <p><a href="http://blogs.claritycon.com/blog/2009/08/custom-panels-in-silverlight-wpf-part-3-animation/" rel="nofollow">Part 3 - Animation</a></p>
  
  <p><a href="http://blogs.claritycon.com/blog/2009/09/custom-panels-in-silverlight-wpf-part-4-virtualization/" rel="nofollow">Part 4 - Virtualization</a></p>