Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let bitmap = new System.Drawing.Bitmap(fst GUI.BoardSize, snd GUI.BoardSize)
- GUI.gamePicture.Image <- bitmap
- let drawGameBoard () =
- let data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), Imaging.ImageLockMode.ReadWrite, bitmap.PixelFormat)
- let size = abs(data.Stride) * data.Height
- let buf = Array.create size 0uy
- System.Runtime.InteropServices.Marshal.Copy (data.Scan0, buf, 0, size)
- for cellX in { 0 .. fst GUI.CellCount - 1 } do
- for cellY in { 0 .. snd GUI.CellCount - 1 } do
- let color = if gameBoard.[cellX, cellY] then 0uy else 255uy
- for x in { 0 .. GUI.CellSize - 1 } do
- for y in { 0 .. GUI.CellSize - 1 } do
- let r = ((cellY * GUI.CellSize + y) * data.Stride) + (cellX * GUI.CellSize + x) * 4
- buf.[r] <- color
- buf.[r+1] <- color
- buf.[r+2] <- color
- buf.[r+3] <- 255uy
- System.Runtime.InteropServices.Marshal.Copy (buf, 0, data.Scan0, size)
- bitmap.UnlockBits(data);
- GUI.gamePicture.Invalidate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement