Browse Source

remove allSystemBrushes from Grid Painter.

Update drawGrid to use "use" statements and remove the manual Dispose calls. Make minor spelling/editing chanes (in comments).
master
Craig Oates 6 years ago
parent
commit
e77baa242d
  1. 11
      DeathSocket/GridPainter.fs
  2. 12
      DeathSocket/ImageServices.fs
  3. 2
      TestCentre/Script.fsx

11
DeathSocket/GridPainter.fs

@ -6,8 +6,6 @@ namespace DeathSocket
open Validation
open ImageServices
open System.Drawing
open System.Reflection
// Needs XML comments.
let applyGridAsync spec =
@ -29,12 +27,3 @@ namespace DeathSocket
// Tests have not been written.
let determineVerticalLines width height columns =
createVerticalLines width height columns
// Needs XML comments.
// Tests have not been written.
let allSystemBrushes =
let properties =
typeof<Brushes>.GetProperties
(BindingFlags.Public ||| BindingFlags.Static)
seq { for prop in properties -> prop }
|> Seq.toList

12
DeathSocket/ImageServices.fs

@ -18,11 +18,11 @@
let drawGrid spec =
// The originalImg is for images with indexed pixels.
let orignialImg = Bitmap.FromFile spec.originalPath
let img = new Bitmap (orignialImg.Width, orignialImg.Height)
let graphics = Graphics.FromImage img
use orignialImg = Bitmap.FromFile spec.originalPath
use img = new Bitmap (orignialImg.Width, orignialImg.Height)
use graphics = Graphics.FromImage img
graphics.DrawImage (orignialImg, 0, 0)
let pen = new Pen (spec.colour, width = spec.penWidth)
use pen = new Pen (spec.colour, width = spec.penWidth)
let horizontalLines =
createHorizontalLines (img.Size.Width) (img.Size.Height) (spec.rows)
let verticalLines =
@ -30,7 +30,3 @@
for line in horizontalLines do graphics.DrawLines (pen, line)
for line in verticalLines do graphics.DrawLines (pen, line)
img.Save (spec.savePath, ImageFormat.Png)
orignialImg.Dispose ()
img.Dispose ()
graphics.Dispose ()
pen.Dispose ()

2
TestCentre/Script.fsx

@ -44,7 +44,7 @@ resetLoadingTestArea ()
(* Populating LoadingTestArea Folder Scripts
===============================================================================
The following scripts are to help you populate a test folder of images.
The following scripts are to help you populate a test folder with test images.
You can then use these images in LibraryTests.fs -- Property Tests.
The tests consists of loading images from LoadingTestArea, transforming them
and saving them in SavingTestArea. *)

Loading…
Cancel
Save