|
|
|
@ -1,12 +1,13 @@
|
|
|
|
|
module internal ImageServices |
|
|
|
|
|
|
|
|
|
open System |
|
|
|
|
open System.IO |
|
|
|
|
open System.Drawing |
|
|
|
|
open System.Drawing.Imaging |
|
|
|
|
open DeathSocket |
|
|
|
|
open Validation |
|
|
|
|
open ColourServices |
|
|
|
|
open SkiaSharp |
|
|
|
|
open System |
|
|
|
|
|
|
|
|
|
(* Note on the Use of Repeated Code |
|
|
|
|
=========================================================================== |
|
|
|
@ -20,10 +21,24 @@
|
|
|
|
|
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 setLineThickness pDimension aDimension lineWidth = |
|
|
|
|
if (pDimension <= 0.0 || aDimension <= 0.0 || lineWidth <= 0.0) then |
|
|
|
|
raise (new DivideByZeroException ("[ERROR] The images height and width must be greater than 0.")) |
|
|
|
|
else lineWidth / (pDimension / aDimension) |
|
|
|
|
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 |
|
|
|
|
======================================================================== *) |
|
|
|
|