title: WriteableBitmap access violation problem
body: <p>The following code always causes an AccessViolationException in the Fill method when the last pixel (x = 255, y = 255) is accessed. However, if I use a size such as 200x200 it works. Same problem with 512 x 512 or 1024 x 1024 or other power-of-two sizes (seems to work fine with 4x4, 8x8 ... up to 32 x 32). Any ideas why that is?</p>
  
  <pre><code>var wb = new WriteableBitmap(256, 256, 96, 96, PixelFormats.Bgr24, null);
  wb.Fill(256, 256, 3, Colors.Black);
  
  ...
  
  public static void Fill(this WriteableBitmap bmp, int width, int height, int bytesPerPixel, Color color)
  {
      var rect = new Int32Rect(0, 0, width, height);
      var fillColor = color.ToInt();
  
      bmp.Lock();
  
      unsafe
      {
        int pBackBuffer = (int)bmp.BackBuffer;
        int stride = bmp.BackBufferStride;
  
        for (int y = 0; y &lt; height; y++)
          for (int x = 0; x &lt; width; x++)
          {
            int offset = y * stride + x * bytesPerPixel;
            int pBackBufferWithOffset = pBackBuffer + offset;
            *((int*) pBackBufferWithOffset) = fillColor;
          }
      }
  
      bmp.AddDirtyRect(rect);
      bmp.Unlock();
  }
  
  private static int ToInt(this Color color)
  {
      int c = color.R &lt;&lt; 16; // R
      c    |= color.G &lt;&lt; 8;  // G
      c    |= color.B &lt;&lt; 0;  // B
      return c;
  }
  </code></pre>