Craig Oates
6 years ago
5 changed files with 26 additions and 24 deletions
@ -1,11 +1,16 @@ |
|||||||
namespace DeathSocket |
namespace DeathSocket |
||||||
|
|
||||||
|
open System.IO |
||||||
|
|
||||||
module GridPainter = |
module GridPainter = |
||||||
|
|
||||||
open Validation |
open Validation |
||||||
open ImageServices |
open ImageServices |
||||||
|
|
||||||
let applyGridToImage spec = |
let applyGrid spec = |
||||||
validateFilePath |> ignore |
try |
||||||
drawGrid spec |
validateFilePath |> ignore |
||||||
0 |
drawGrid spec |> ignore |
||||||
|
with |
||||||
|
| :? FileNotFoundException as ex -> printfn"%s" ex.Message |
||||||
|
|
@ -1,34 +1,32 @@ |
|||||||
module internal ImageServices |
module internal ImageServices |
||||||
|
|
||||||
open System.Drawing |
open System.Drawing |
||||||
open DeathSocket.Domain |
open System.Drawing.Imaging |
||||||
open System.Drawing.Imaging |
open DeathSocket |
||||||
|
|
||||||
let createHorizontalLines width height columns = |
let createHorizontalLines width height rows = |
||||||
let interval = width / columns |
let interval = width / rows |
||||||
[| for point in 1 .. columns -> |
[| for point in 1 .. (rows - 1) -> |
||||||
[|Point (0, (interval * point)) |
[|Point (0, (interval * point)) |
||||||
Point (height, (interval * point) )|]|] |
Point (height, (interval * point) )|]|] |
||||||
|
|
||||||
let createVerticalLines width height columns = |
let createVerticalLines height columns = |
||||||
let interval = height / columns |
let interval = height / columns |
||||||
[| for point in 1 .. columns -> |
[| for point in 1 .. (columns - 1) -> |
||||||
[| Point ((interval * point), 0) |
[| Point ((interval * point), 0) |
||||||
Point ((interval * point), height)|]|] |
Point ((interval * point), height)|]|] |
||||||
|
|
||||||
let drawGrid spec = |
let drawGrid spec = |
||||||
let img = Bitmap.FromFile spec.filePath |
let img = Bitmap.FromFile spec.originalPath |
||||||
let graphics = Graphics.FromImage img |
let graphics = Graphics.FromImage img |
||||||
let pen = new Pen (spec.colour, width = spec.penWidth) |
let pen = new Pen (spec.colour, width = spec.penWidth) |
||||||
let horizontalLines = |
let horizontalLines = |
||||||
createHorizontalLines (img.Size.Width) (img.Size.Height) (spec.columns) |
createHorizontalLines (img.Size.Width) (img.Size.Height) (spec.columns) |
||||||
let verticalLines = |
let verticalLines = createVerticalLines (img.Size.Height) (spec.columns) |
||||||
createVerticalLines (img.Size.Width) (img.Size.Height) (spec.columns) |
|
||||||
for line in horizontalLines do graphics.DrawLines (pen, line) |
for line in horizontalLines do graphics.DrawLines (pen, line) |
||||||
for line in verticalLines do graphics.DrawLines (pen, line) |
for line in verticalLines do graphics.DrawLines (pen, line) |
||||||
img.Save (spec.savePath, ImageFormat.Png) |
img.Save (spec.savePath, ImageFormat.Png) |
||||||
img.Dispose () |
img.Dispose () |
||||||
graphics.Dispose () |
graphics.Dispose () |
||||||
pen.Dispose () |
pen.Dispose () |
||||||
0 |
() |
||||||
|
|
Loading…
Reference in new issue