title: Invalid parameters in CGBitmapContext constructor
body: <p>I'm trying to create a blank bitmap in a Xamarin.iOS project using the <a href="https://developer.xamarin.com/api/type/MonoTouch.CoreGraphics.CGBitmapContext/" rel="nofollow noreferrer">CGBitmapContext constructor(s)</a>.  However, no matter what I try I just get the error <code>"System.Exception: Invalid parameters to context creation"</code></p>
  
  <p>Example code:</p>
  
  <pre><code>const int width = 100;
  const int height = 100;
  const int bytesPerPixel = 4;
  const int bitsPerComponent = 8;
  var intBytes = width * height * bytesPerPixel;
  byte[] pixelData = new byte[intBytes];
  var colourSpace = CGColorSpace.CreateDeviceRGB();
  using (var objContext = new CGBitmapContext(pixelData, width, height, bitsPerComponent, width * bytesPerPixel, colourSpace, CGBitmapFlags.ByteOrderDefault))
  {
      // ...
  }
  </code></pre>
  
  <p>I have tried changing most of the parameters; I tried fixing the data block and passing it as an IntPtr.  I tried using  null as the first parameter so that the system would allocate the data.  And I've tried various flags in the last parameter.  I always get that same error.  What parameter is wrong?  And what needs to be changed in the code above to make it  execute?</p>