Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 1.17 KB | None | 0 0
  1.     let bitmap = new System.Drawing.Bitmap(fst GUI.BoardSize, snd GUI.BoardSize)
  2.     GUI.gamePicture.Image <- bitmap
  3.  
  4.     let drawGameBoard () =
  5.         let data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), Imaging.ImageLockMode.ReadWrite, bitmap.PixelFormat)
  6.         let size = abs(data.Stride) * data.Height
  7.         let buf = Array.create size 0uy
  8.         System.Runtime.InteropServices.Marshal.Copy (data.Scan0, buf, 0, size)
  9.         for cellX in { 0 .. fst GUI.CellCount - 1 } do
  10.             for cellY in { 0 .. snd GUI.CellCount - 1 } do
  11.                 let color = if gameBoard.[cellX, cellY] then 0uy else 255uy
  12.                 for x in { 0 .. GUI.CellSize - 1 } do
  13.                     for y in { 0 .. GUI.CellSize - 1 } do
  14.                         let r = ((cellY * GUI.CellSize + y) * data.Stride) + (cellX * GUI.CellSize + x) * 4
  15.                         buf.[r] <- color
  16.                         buf.[r+1] <- color
  17.                         buf.[r+2] <- color
  18.                         buf.[r+3] <- 255uy
  19.         System.Runtime.InteropServices.Marshal.Copy (buf, 0, data.Scan0, size)
  20.         bitmap.UnlockBits(data);
  21.         GUI.gamePicture.Invalidate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement