diff --git a/DeathSocket/GridPainter.fs b/DeathSocket/GridPainter.fs
index 5ff908b..e06a7ff 100644
--- a/DeathSocket/GridPainter.fs
+++ b/DeathSocket/GridPainter.fs
@@ -3,6 +3,8 @@ namespace DeathSocket
open System.IO
/// Provides functions which help draw gridded overlays onto images.
+ /// Grid Painter, and all of Death Socket, uses the System.Drawing brushes/colours.
+ /// If you are using System.Media brushes and colour, you will need to convert them.
module GridPainter =
open Validation
@@ -43,6 +45,7 @@ namespace DeathSocket
/// The width of the image.
/// The height of the image.
/// The number of rows the grid should have.
+ /// You will probably only need these when dealing with GUI's.
let determineHorizontalLines width height rows =
createHorizontalLines width height rows
@@ -53,5 +56,6 @@ namespace DeathSocket
/// The width of the image.
/// The height of the image.
/// The number of columns the grid should have.
+ /// You will probably only need these when dealing with GUI's.
let determineVerticalLines width height columns =
createVerticalLines width height columns
\ No newline at end of file
diff --git a/DeathSocket/ImageServices.fs b/DeathSocket/ImageServices.fs
index 51b4fa9..20ed85f 100644
--- a/DeathSocket/ImageServices.fs
+++ b/DeathSocket/ImageServices.fs
@@ -3,6 +3,7 @@
open System.Drawing
open System.Drawing.Imaging
open DeathSocket
+ open System.Drawing.Drawing2D
let createHorizontalLines width height rows =
let interval = height / rows
@@ -17,16 +18,16 @@
Point ((interval * point), height)|]|]
let drawGrid spec =
- // The originalImg is for images with indexed pixels.
- use orignialImg = Bitmap.FromFile spec.originalPath
- use img = new Bitmap (orignialImg.Width, orignialImg.Height)
- use graphics = Graphics.FromImage img
- graphics.DrawImage (orignialImg, 0, 0)
- use pen = new Pen (spec.colour, width = spec.penWidth)
+ let img = Bitmap.FromFile spec.originalPath
+ let graphics = Graphics.FromImage(img)
+ let pen = new Pen (spec.colour, width = spec.penWidth)
let horizontalLines =
createHorizontalLines (img.Size.Width) (img.Size.Height) (spec.rows)
let verticalLines =
createVerticalLines (img.Size.Width) (img.Size.Height) (spec.columns)
for line in horizontalLines do graphics.DrawLines (pen, line)
for line in verticalLines do graphics.DrawLines (pen, line)
- img.Save (spec.savePath, ImageFormat.Png)
\ No newline at end of file
+ img.Save (spec.savePath)
+ img.Dispose()
+ graphics.Dispose()
+ pen.Dispose()
\ No newline at end of file
diff --git a/DeathSocketCLI/Validation.fs b/DeathSocketCLI/Validation.fs
index e4cd715..1225133 100644
--- a/DeathSocketCLI/Validation.fs
+++ b/DeathSocketCLI/Validation.fs
@@ -48,8 +48,8 @@
columns = numColumns }
let buildDefaultSpec imgPath newPath =
- let stream = new FileStream (imgPath, FileMode.Open)
- let image = Image.FromStream (stream, false, false)
+ use stream = new FileStream (imgPath, FileMode.Open)
+ use image = Image.FromStream (stream, false, false)
let spec =
{ originalPath = imgPath
savePath = newPath
@@ -58,4 +58,5 @@
rows = 10
columns = 10 }
stream.Dispose ()
- image.Dispose ()
\ No newline at end of file
+ image.Dispose ()
+ spec
\ No newline at end of file