|
|
|
@ -8,20 +8,18 @@ module ImageMaker =
|
|
|
|
|
|
|
|
|
|
type OverlayType = |
|
|
|
|
| Border |
|
|
|
|
| Complete |
|
|
|
|
| Full |
|
|
|
|
|
|
|
|
|
type OverlaySpec = { |
|
|
|
|
colour: Brush; |
|
|
|
|
overlayType: OverlayType |
|
|
|
|
} |
|
|
|
|
type OverlaySpec = |
|
|
|
|
{ colour: Brush; |
|
|
|
|
overlayType: OverlayType } |
|
|
|
|
|
|
|
|
|
type ImageSpec = { |
|
|
|
|
width: int; |
|
|
|
|
height: int; |
|
|
|
|
colour: Brush; |
|
|
|
|
filePath: string; |
|
|
|
|
overlay: OverlaySpec |
|
|
|
|
} |
|
|
|
|
type ImageSpec = |
|
|
|
|
{ width: int; |
|
|
|
|
height: int; |
|
|
|
|
colour: Brush; |
|
|
|
|
filePath: string; |
|
|
|
|
overlay: OverlaySpec } |
|
|
|
|
|
|
|
|
|
let private validateDimension dimension = |
|
|
|
|
match dimension with |
|
|
|
@ -49,3 +47,23 @@ module ImageMaker =
|
|
|
|
|
| :? ArgumentException as ex -> return ex.Message |
|
|
|
|
| _ as ex -> return ex.Message |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let 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) |
|
|
|
|
|
|
|
|
|
let makeImage2 spec = |
|
|
|
|
async { |
|
|
|
|
try |
|
|
|
|
validateDimension spec.width |
|
|
|
|
validateDimension spec.height |
|
|
|
|
validateDirectory spec.filePath |
|
|
|
|
// add option code for overlay here |
|
|
|
|
drawMainImage spec |
|
|
|
|
return "Image saved." |
|
|
|
|
with |
|
|
|
|
| :? ArgumentException as ex -> return ex.Message |
|
|
|
|
| _ as ex -> return ex.Message |
|
|
|
|
} |
|
|
|
|