title: How to efficiently write pixels to the screen with Direct2D
body: <p>I have a array of pixels (m_pixels) that I want to render to the screen using Direct2D.
  The array contains 10,000 elements (100 rows of 100 pixels). The code below loops over the pixels and draws them to the screen as 10x10 rectangles. Is there a more efficient way of performing this operation? How can I add a GaussianBlur effect to the pixels/image? </p>
  
  <pre><code>m_d2dContext-&gt;BeginDraw();
  m_d2dContext-&gt;Clear(ColorF(0.0f, 0.0f, 0.0f));
  
  
  
  // Render m_pixels
  // m_pixels is updated by the solver directly before render
  auto rect = D2D1_RECT_F();
  ComPtr&lt;ID2D1SolidColorBrush&gt; pBlackBrush;
  DX::ThrowIfFailed(m_d2dContext-&gt;CreateSolidColorBrush(ColorF(1.0f, 0.0f, 0.0f),&amp;pBlackBrush));
  
  for (int i=0; i&lt;10000; i++){
      //Update the color
      pBlackBrush-&gt;SetColor(D2D1::ColorF(m_pixels[i]*3, m_pixels[i], m_pixels[i]));
      //Update the rectangle size
      rect.top = 10*floor(i/100);
      rect.left = 10*floor(i%100);
      rect.bottom = 10*floor(i/100) + 10;
      rect.right = 10*floor(i%100) + 10;
      //Set the rectangle color
      m_d2dContext-&gt;FillRectangle(rect, pBlackBrush.Get());
  }
  
  HRESULT hr = m_d2dContext-&gt;EndDraw();
  </code></pre>