From be1b9a17d958c509e2bff43004ffa1458648e5c1 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Mon, 31 Dec 2018 15:22:10 +0000 Subject: [PATCH] move (some) ImageServies code to ImagePrep. --- DeathSocket/ImageServices.fs | 56 +----------------------------------- 1 file changed, 1 insertion(+), 55 deletions(-) diff --git a/DeathSocket/ImageServices.fs b/DeathSocket/ImageServices.fs index 4c1ae10..9949829 100644 --- a/DeathSocket/ImageServices.fs +++ b/DeathSocket/ImageServices.fs @@ -1,12 +1,11 @@ module internal ImageServices - open System open System.IO open System.Drawing open System.Drawing.Imaging open DeathSocket - open ValidationServices open ColourServices + open ImagePrep open SkiaSharp (* Note on the Use of Repeated Code @@ -21,46 +20,9 @@ lurking in an end users RAM can grind their computer to a halt. On top of that, they have no means to make alterations to the code. *) - let determineImageScale pDimension aDimension = - (double aDimension) / (double pDimension) - - let determineLineScale (lineWidth: double) (scale: double) = - lineWidth / scale - - let adjustLineThickness pDimensions aDimensions lineWidth = - match (validateLongestDimension pDimensions aDimensions) with - | Width -> - let thickness = - determineImageScale (fst pDimensions) (fst aDimensions) - |> determineLineScale lineWidth - thickness - | Height -> - let thickness = - determineImageScale (snd pDimensions) (snd aDimensions) - |> determineLineScale lineWidth - thickness - (* SkiaSharp Functions ======================================================================== *) - let createSKHorizontalLines width height rows = - let interval = float32 (height / rows) - [|for point in 1 .. (rows - 1) -> - [| SKPoint ((float32 0), (interval * (float32 point))) - SKPoint ((float32 width), (interval * (float32 point)))|]|] - - let createSKVerticalLines width height columns = - let interval = float32 (width / columns) - [| for point in 1 .. (columns - 1) -> - [| SKPoint ((interval * (float32 point)), (float32 0)) - SKPoint ((interval * (float32 point)), (float32 height))|]|] - - let determineSkiaDimensions filePath = - use fileStream = File.Open (filePath, FileMode.Open) - use skStream = new SKManagedStream (fileStream) - use bitmap = SKBitmap.Decode (skStream) - (bitmap.Width, bitmap.Height) - // Does not work when using SkiaSharp NuGet v. 1.68 let drawSkiaGrid (spec: SkiaSpec) = use fileStream = File.Open (spec.originalPath, FileMode.Open) @@ -222,22 +184,6 @@ (* System.Drawing Functions ======================================================================== *) - let createHorizontalLines width height rows = - let interval = height / rows - [| for point in 1 .. (rows - 1) -> - [|Point (0, (interval * point)) - Point (width, (interval * point) )|]|] - - let createVerticalLines width height columns = - let interval = width / columns - [| for point in 1 .. (columns - 1) -> - [| Point ((interval * point), 0) - Point ((interval * point), height)|]|] - - let determineSystemDrawingDimensions filePath = - use bitmap = Bitmap.FromFile filePath - (bitmap.Width, bitmap.Height) - (* Note on Use of Temp. File in Functions which Add A Grid Overlay =========================================================================== The temp. file is used in the functions below are there to convert images