@ -255,12 +255,30 @@
clone.Save ( s p e c . s a v e P a t h )
clone.Save ( s p e c . s a v e P a t h )
let drawRGBAGridGrey (spec: RGBASpec) =
let drawRGBAGridGrey (spec: RGBASpec) =
// THIS NEEDS REFACTORING TO CONVERT IMAGE TO G R E Y S C A L E .
// This part converts the images to g r e y s c a l e .
use original = Bitmap.FromFile s p e c . o r i g i n a l P a t h
use original = Bitmap.FromFile s p e c . o r i g i n a l P a t h
use temp = new Bitmap ( o r i g i n a l )
use temp = new Bitmap ( o r i g i n a l )
use clone =
use clone = new Bitmap(temp.Width, t e m p . H e i g h t )
temp.Clone (new Rectangle(0, 0 , temp.Width, temp.Height), P i x e l F o r m a t . F o r m a t 32 b p p A r g b )
use g = G r a p h i c s . F r o m I m a g e ( c l o n e )
// This can be refactored out into its own function or reachable from
// anywhere in this module. It's used more than once and doesn't use ' u s e ' .
let aM: float32[][] = [ |
[| (float32 0 .3 ); (float32 0 .3 ); (float32 0 .3 ); (float32 0 .0 ); (float32 0 .0 ) | ] ;
[| (float32 0 .59 ); (float32 0 .59 ); (float32 0 .59 ); (float32 0 .0 ); (float32 0 .0 ) | ] ;
[| (float32 0 .11 ); (float32 0 .11 ); (float32 0 .11 ); (float32 0 .0 ); (float32 0 .0 ) | ] ;
[| (float32 0 .0 ); (float32 0 .0 ); (float32 0 .0 ); (float32 1 .0 ); (float32 0 .0 ) | ] ;
[| (float32 0 .0 ); (float32 0 .0 ); (float32 0 .0 ); (float32 0 .0 ); (float32 1 .0 ) | ] ;
| ]
let colourMatrix = new ColorMatrix(aM) // Maybe put in own f u n c t i o n ?
use attributes = new I m a g e A t t r i b u t e s ( )
a t t r i b u t e s . S e t C o l o r M a t r i x ( c o l o u r M a t r i x )
g.DrawImage(temp, new Rectangle(0, 0 , temp.Width, t e m p . H e i g h t ) ,
0 , 0 , temp.Width, temp.Height, GraphicsUnit.Pixel, a t t r i b u t e s )
use graphics = G r a p h i c s . F r o m I m a g e ( c l o n e )
use graphics = G r a p h i c s . F r o m I m a g e ( c l o n e )
// This part applies the g r i d .
use pen = new Pen ((makeBrushFromRGBASpec spec), width = s p e c . p e n W i d t h )
use pen = new Pen ((makeBrushFromRGBASpec spec), width = s p e c . p e n W i d t h )
graphics.DrawImage (original,new Rectangle(0, 0 , clone.Width, c l o n e . H e i g h t ) )
graphics.DrawImage (original,new Rectangle(0, 0 , clone.Width, c l o n e . H e i g h t ) )
let horizontalLines =
let horizontalLines =