|
|
|
@ -19,7 +19,7 @@ module ImageMaker =
|
|
|
|
|
height: int; |
|
|
|
|
colour: Brush; |
|
|
|
|
filePath: string; |
|
|
|
|
overlay: OverlaySpec } |
|
|
|
|
overlay: OverlaySpec option } |
|
|
|
|
|
|
|
|
|
let private validateDimension dimension = |
|
|
|
|
match dimension with |
|
|
|
@ -32,6 +32,7 @@ module ImageMaker =
|
|
|
|
|
| false -> invalidArg "filePath" "Unable to save to the specified location because it does not exist." |
|
|
|
|
| true -> () |
|
|
|
|
|
|
|
|
|
// This function is to be deleted. |
|
|
|
|
let makeImage width height colour filepath = |
|
|
|
|
async { |
|
|
|
|
try |
|
|
|
@ -48,21 +49,26 @@ module ImageMaker =
|
|
|
|
|
| _ as ex -> return ex.Message |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let drawMainImage spec = |
|
|
|
|
let private drawMainImage spec = |
|
|
|
|
use bitmap = new Bitmap(spec.width, spec.height) |
|
|
|
|
use graphics = Graphics.FromImage(bitmap) |
|
|
|
|
graphics.FillRectangle(spec.colour, new Rectangle(0, 0, bitmap.Width, bitmap.Height)) |
|
|
|
|
bitmap.Save(spec.filePath) |
|
|
|
|
printfn "[SUCCESS] Image saved." |
|
|
|
|
|
|
|
|
|
let private drawImageWithOverlay spec = printfn "Overlay section is not complete." |
|
|
|
|
|
|
|
|
|
let makeImage2 spec = |
|
|
|
|
async { |
|
|
|
|
try |
|
|
|
|
printfn "[INFO.] Attempting to make image..." |
|
|
|
|
validateDimension spec.width |
|
|
|
|
validateDimension spec.height |
|
|
|
|
validateDirectory spec.filePath |
|
|
|
|
// add option code for overlay here |
|
|
|
|
drawMainImage spec |
|
|
|
|
return "Image saved." |
|
|
|
|
match Option.isSome spec.overlay with |
|
|
|
|
| true -> drawImageWithOverlay spec |
|
|
|
|
| false -> drawMainImage spec |
|
|
|
|
return "[SUCCESS.] Image creation attempt complete." |
|
|
|
|
with |
|
|
|
|
| :? ArgumentException as ex -> return ex.Message |
|
|
|
|
| _ as ex -> return ex.Message |
|
|
|
|