title: How to work with pixels using Direct2D
body: <p>Could somebody provide an example of an efficient way to work with pixels using Direct2D?</p>
  
  <p>For example, how can I swap <em>all</em> green pixels (<code>RGB = 0x00FF00</code>) with red pixels (<code>RGB = 0xFF0000</code>) on a render target? What is the standard approach? Is it possible to use <code>ID2D1HwndRenderTarget</code> for that? Here I assume using some kind of hardware acceleration. Should I create a different object for direct pixels manipulations?</p>
  
  <p>Using DirectDraw I would use <code>BltFast</code> method on the <code>IDirectDrawSurface7</code> with logical operation. Is there something similar with Direct2D?</p>
  
  <p>Another task is to generate complex images dynamically where each point location and color is a result of a mathematical function. For the sake of an example let's simplify everything and draw <code>Y = X ^ 2</code>. How to do that with Direct2D? Ultimately I'm going to need to draw complex functions but if somebody could give me a simple example for <code>Y = X ^ 2</code>.</p>