Browse Source

update comments an remove obsolete functions.

master
Craig Oates 6 years ago
parent
commit
ee2911e071
  1. 34
      DeathSocket/Domain.fs
  2. 46
      DeathSocket/GridPainter.fs
  3. 9
      DeathSocket/ImageServices.fs

34
DeathSocket/Domain.fs

@ -5,30 +5,8 @@
module Domain =
open System.Drawing
open System
/// <summary>
/// The specification used by Death Socket when adding a grid to an image.
/// </summary>
[<Obsolete "Please use the BrushSpec type.">]
type ImageSpec =
{ /// The original path of the image which the grid is being added to.
originalPath: string
/// The location of the new gridded image.
savePath: string
/// The (System.Drawing) brush used to draw the grid. This determines the colour.
colour: Brush
/// The thickness of the line on the grid.
penWidth: float32
/// The number of rows the grid will have.
rows: int
///The number of columns the grid will have.
columns: int }
/// <summary>
/// The specification which uses System.Drawing brush to draw a grid.
/// </summary>
// REPLACING IMAGESPEC
type BrushSpec =
{ /// The original path of the image which the grid is being added to.
originalPath: string
@ -43,6 +21,8 @@
///The number of columns the grid will have.
columns: int }
/// The specification which uses includes individual RGBA values to
/// draw a grid.
type RGBASpec =
{ originalPath: string
savePath: string
@ -52,14 +32,4 @@
blue: float
penWidth: float32
rows: int
columns: int }
type CMYKSpec =
{ originalPath: string
savePath: string
cyan: float
magenta: float
yellow: float
key: float32
rows: int
columns: int }

46
DeathSocket/GridPainter.fs

@ -12,7 +12,7 @@ namespace DeathSocket
open ImageServices
/// <summary>
/// Uses the information included in spec and creates a gridded image.
/// Uses the information included in spec to create a gridded image.
/// It then asynchronously saves it.
/// Please stick to .bmp, .jpg or .png files.
/// The other (image) file types have not been tested.
@ -30,7 +30,6 @@ namespace DeathSocket
/// This is because it is locked whilst in this function.
/// </remarks>
let applyBrushSpecGridAsync (spec: BrushSpec) =
// The spec is to be changed to Brush Spec.
async {
try
validateFilePath spec.originalPath |> ignore
@ -41,6 +40,23 @@ namespace DeathSocket
printfn "File could not be found at %s" ex.Message
}
/// <summary>
/// Uses the information included in spec to create a gridded image. It
/// then asynchronously saves it. Please stick to .bmp, .jpg or .png
/// files. The other (image) file types have not been tested.
/// </summary>
/// <param name="spec">
/// The specification used to generate the gridded image.
/// </param>
/// <exeption cref="System.IO.FileNotFoundException">
/// If the file the grid is being applied to cannot be found,
/// a FileNotFoundException will be thrown.
/// </exception>
/// <remarks
/// Make sure the image, which is having the overlay added to it,
/// is not in use or needed by another program/process.
/// This is because it is locked whilst in this function.
/// </remarks>
let applyRGBAGridAsync (spec: RGBASpec) =
async {
try
@ -52,15 +68,31 @@ namespace DeathSocket
printfn "File could not be found at %s" ex.Message
}
/// <summary>
/// Creates a Sytsem.Drawing SolidBrush from the individual RGBA values.
/// </summary>
/// <param name="r">The red value.</param>
/// <param name="g">The green value.</param>
/// <param name="b">The blue value.</param>
/// <param name="a">The alpha value.</param>
/// <remarks>
/// Death Socket uses System.Drawing and not System.Media for colours
/// and brushes.
/// </remarks>
let makeSolidBrushFromRGBA r g b a = makeBrushFromRGBA r g b a
/// <summary>
/// Creates a System.Drawing SolidBrush from a RGBASpec.
/// </summary>
/// <param name="spec">
///The specification which the brush is made from.
///</param>
/// <remarks>
/// Death Socket uses System.Drawing and not System.Media for colours
/// and brushes.
/// </remarks>
let makeSolidBrushFromRGBASpec spec = makeBrushFromRGBASpec spec
// let applyCMYKGridAsync -- to be added at a later date.
// not tested or completed.
//let makeSolidBrushFromCMYK c m y k = ""
/// <summary>
/// Determines the (Pen) points needed to draw the appropriate number of horizontal lines (I.E. rows).
/// Each item in the array includes a start and end co-ordinate (point) for each line.

9
DeathSocket/ImageServices.fs

@ -3,7 +3,6 @@
open System.Drawing
open System.Drawing.Imaging
open DeathSocket
open Validation
open ColourServices
let createHorizontalLines width height rows =
@ -18,8 +17,13 @@
[| Point ((interval * point), 0)
Point ((interval * point), 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
with indexed pixels. Instead of listig them all, just assume any function
with a "*Spec" type as a parameter will use this "temp" file. *)
let drawBrushSpecGrid (spec: BrushSpec) =
// The temp. file is used as a way to convert images with indexed pixels.
use original = Bitmap.FromFile spec.originalPath
use temp = new Bitmap(original)
use clone = temp.Clone(new Rectangle(0, 0, temp.Width, temp.Height), PixelFormat.Format32bppArgb)
@ -35,7 +39,6 @@
clone.Save (spec.savePath)
let drawRGBAGrid (spec: RGBASpec) =
// The temp. file is used as a way to convert images with indexed pixels.
use original = Bitmap.FromFile spec.originalPath
use temp = new Bitmap(original)
use clone = temp.Clone(new Rectangle(0, 0, temp.Width, temp.Height), PixelFormat.Format32bppArgb)

Loading…
Cancel
Save