Browse Source

Merge pull request #3 from CraigOates/0.3-proto

update the drawGrid function to work with images with indexed pixels.
master
Craig Oates 6 years ago committed by GitHub
parent
commit
48bbd1fe3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      DeathSocket/ImageServices.fs

19
DeathSocket/ImageServices.fs

@ -18,16 +18,17 @@
Point ((interval * point), height)|]|] Point ((interval * point), height)|]|]
let drawGrid spec = let drawGrid spec =
let img = Bitmap.FromFile spec.originalPath // The temp. file is used as a way to convert images with index pixels.
let graphics = Graphics.FromImage(img) use original = Bitmap.FromFile spec.originalPath
let pen = new Pen (spec.colour, width = spec.penWidth) use temp = new Bitmap(original)
use clone = temp.Clone(new Rectangle(0, 0, temp.Width, temp.Height), PixelFormat.Format32bppArgb)
use graphics = Graphics.FromImage(clone)
use pen = new Pen (spec.colour, width = spec.penWidth)
graphics.DrawImage(original,new Rectangle(0, 0, clone.Width, clone.Height))
let horizontalLines = let horizontalLines =
createHorizontalLines (img.Size.Width) (img.Size.Height) (spec.rows) createHorizontalLines (clone.Size.Width) (clone.Size.Height) (spec.rows)
let verticalLines = let verticalLines =
createVerticalLines (img.Size.Width) (img.Size.Height) (spec.columns) createVerticalLines (clone.Size.Width) (clone.Size.Height) (spec.columns)
for line in horizontalLines do graphics.DrawLines (pen, line) for line in horizontalLines do graphics.DrawLines (pen, line)
for line in verticalLines do graphics.DrawLines (pen, line) for line in verticalLines do graphics.DrawLines (pen, line)
img.Save (spec.savePath) clone.Save (spec.savePath)
img.Dispose()
graphics.Dispose()
pen.Dispose()
Loading…
Cancel
Save