I am trying to create a bitmap from an array of pixels.
var height = 2;
var width = 2;
var output = new byte[4] { 0, 0, 0, 0 };
var gcHandle = GCHandle.Alloc(output, GCHandleType.Pinned);
var stride = width * sizeof(byte);
var pointer = gcHandle.AddrOfPinnedObject();
using (var bitmap = new Bitmap(width, height, stride, PixelFormat.Format8bppIndexed, pointer))
{
}
However I get System.ArgumentException: 'Parameter is not valid.', with no inner exception or further details.
I don't want to use SetPixel because my real array is very large.
This is using the System.Drawing.Common 4.5.0 library for .Net Standard 2.0