|
|
|
@ -50,13 +50,47 @@ module ImageMaker =
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
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." |
|
|
|
|
(* |
|
|
|
|
Need to call dispose manually because of how the image is/can be built-up. |
|
|
|
|
need to reduce the amount of branching code... it's getting unwieldy. |
|
|
|
|
create bitmap |
|
|
|
|
create graphics |
|
|
|
|
draw base |
|
|
|
|
check overlay |
|
|
|
|
add border |
|
|
|
|
add full overlay |
|
|
|
|
write image to disk |
|
|
|
|
dispose resources |
|
|
|
|
write output message*) |
|
|
|
|
|
|
|
|
|
let private createBorderPositions spec = |
|
|
|
|
[|Point (0, 0); |
|
|
|
|
Point (spec.width, 0); |
|
|
|
|
Point (spec.width, spec.height); |
|
|
|
|
Point (spec.height, 0); |
|
|
|
|
Point (0, 0)|] |
|
|
|
|
|
|
|
|
|
let private drawImageWithBorder spec = |
|
|
|
|
let overlay = spec.overlay.Value |
|
|
|
|
use bitmap = new Bitmap (spec.width, spec.height) |
|
|
|
|
use graphics = Graphics.FromImage (bitmap) |
|
|
|
|
use pen = new Pen (overlay.colour) |
|
|
|
|
let border = createBorderPositions spec |
|
|
|
|
graphics.DrawLines (pen, border) |
|
|
|
|
printfn "Overlay image function not finished." |
|
|
|
|
|
|
|
|
|
let private drawImageWithFullOverlay spec = () |
|
|
|
|
|
|
|
|
|
let private drawImageWithOverlay spec = |
|
|
|
|
match spec.overlay.Value.overlayType with |
|
|
|
|
| Border -> drawImageWithBorder spec |
|
|
|
|
| Full -> drawImageWithFullOverlay spec |
|
|
|
|
|
|
|
|
|
let makeImage2 spec = |
|
|
|
|
async { |
|
|
|
@ -68,7 +102,7 @@ module ImageMaker =
|
|
|
|
|
match Option.isSome spec.overlay with |
|
|
|
|
| true -> drawImageWithOverlay spec |
|
|
|
|
| false -> drawMainImage spec |
|
|
|
|
return "[SUCCESS.] Image creation attempt complete." |
|
|
|
|
return "[SUCCESS] Image creation attempt complete." |
|
|
|
|
with |
|
|
|
|
| :? ArgumentException as ex -> return ex.Message |
|
|
|
|
| _ as ex -> return ex.Message |
|
|
|
|