public unsafe static Bitmap ToBitmap(ImageGrid grid) { grid.EnsureNotDisposed(); var bitmap = new Bitmap(grid.Width, grid.Height, PixelFormat.Format32bppArgb); var bounds = new Rectangle(0, 0, grid.Width, grid.Height); var data = bitmap.LockBits(bounds, ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb); try { fixed(byte *inputPtr = &Unsafe.As <RgbColor, byte>(ref grid._data[0])) { Unsafe.CopyBlock(data.Scan0.ToPointer(), inputPtr, (uint)(data.Stride * data.Height)); } } finally { bitmap.UnlockBits(data); } return(bitmap); }
public ImageTile(ImageGrid grid, int x, int y) { _grid = grid ?? throw new ArgumentNullException(nameof(grid)); X = x; Y = y; }