title: Why is this particular image causing my application to crash with an OutOfMemoryException?
body: <p>Why is this particular image causing my application to crash with an OutOfMemoryException?</p>
  
  <p><img src="https://i.stack.imgur.com/Z08R5.png" alt="enter image description here"></p>
  
  <p>I created a really simple WPF Windows Application with a simple window:</p>
  
  <pre><code>&lt;Window x:Class="DeleteMe.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Grid&gt;
          &lt;Image Source="C:\Path\To\The\Image\MyImage.png" RenderOptions.BitmapScalingMode="Fant"&gt;&lt;/Image&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <ul>
  <li>It doesn't matter if it is x86 or x64.</li>
  <li>If I resize the image file even by 1 pixel it works.</li>
  <li>If I add a few pixels to the image and save it, it still doesn't work.</li>
  <li>The problem occurs only with <code>Fant</code> and <code>HighQuality</code> bitmap scaling modes.</li>
  </ul>
  
  <p>The reason this is a problem is that I don't want to have to resize every image we get from the person that is creating these images. I am using Paint.Net to work with the images as is said person.</p>
  
  <p>Thanks.</p>
  
  <p>My event viewer gives me the following:</p>
  
  <pre><code>Application: DeleteMe.exe
  Framework Version: v4.0.30319
  Description: The process was terminated due to an unhandled exception.
  Exception Info: System.OutOfMemoryException
  Stack:
     at System.Windows.Media.Composition.DUCE+Channel.SyncFlush()
     at System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean, System.Nullable`1
  &lt;ChannelSet&gt;)
     at System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr)
     at System.Windows.Interop.HwndTarget.HandleMessage(MS.Internal.Interop.WindowMessage, IntPtr, IntPtr)
     at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
     at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
     at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
     at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
     at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
     at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
     at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
     at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
     at MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr, Int32, IntPtr, IntPtr)
     at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
     at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
     at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
     at MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr, Int32, IntPtr, IntPtr)
     at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
     at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
     at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
     at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
     at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
     at System.Windows.Threading.Dispatcher.Run()
     at System.Windows.Application.RunDispatcher(System.Object)
     at System.Windows.Application.RunInternal(System.Windows.Window)
     at System.Windows.Application.Run(System.Windows.Window)
     at System.Windows.Application.Run()
     at DeleteMe.App.Main()
  </code></pre>