title: Image top-down from web camera
body: <p>I get the footage from the camera. Like this:</p>
  
  <p>Initialize:</p>
  
  <pre><code>uint pcount = (uint)(capGrabber.Width * capGrabber.Height * PixelFormats.Bgr32.BitsPerPixel / 8);
  section = CreateFileMapping(new IntPtr(-1), IntPtr.Zero, 0x04, 0, pcount, null);
  map = MapViewOfFile(section, 0xF001F, 0, 0, pcount);
  BitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromMemorySection(section, capGrabber.Width, capGrabber.Height, PixelFormats.Bgr32, capGrabber.Width * PixelFormats.Bgr32.BitsPerPixel / 8, 0) as InteropBitmap;
  capGrabber.Map = map;
  </code></pre>
  
  <p>where</p>
  
  <pre><code>IntPtr map;
  IntPtr section;
  InteropBitmap BitmapSource;
  </code></pre>
  
  <p>Graber (capGrabber):</p>
  
  <pre><code>public int BufferCB(double sampleTime, IntPtr pBuffer, int bufferLen)
  {
      if (Map != IntPtr.Zero)
      {
          CopyMemory(Map, pBuffer, bufferLen);
          OnNewFrameArrived();
      }
  
      return 0;            
  }
  </code></pre>
  
  <p>I get the image upside down (top-down). Need to fix this. I found some stuff (use structure BITMAPINFO), but I have not worked. Ask any ideas.</p>