private void SetPixel(int x, int y, ushort color) { if ((x < 0) || (x >= Width) || (y < 0) || (y >= Height)) return; var index = ((y * Width) + x) * sizeof(ushort) - y * 4; if (index < 0 || index >= SpiBuffer.Length) return; SpiBuffer[index] = (byte) (color >> 8); SpiBuffer[++index] = (byte)(color); }
seems to have done the trick. The check on the index is just there because I was debugging.